xref: /openbmc/linux/drivers/gpu/drm/arm/malidp_hw.h (revision 62862cfb)
1ad49f860SLiviu Dudau /*
2ad49f860SLiviu Dudau  *
3ad49f860SLiviu Dudau  * (C) COPYRIGHT 2013-2016 ARM Limited. All rights reserved.
4ad49f860SLiviu Dudau  *
5ad49f860SLiviu Dudau  * This program is free software and is provided to you under the terms of the
6ad49f860SLiviu Dudau  * GNU General Public License version 2 as published by the Free Software
7ad49f860SLiviu Dudau  * Foundation, and any use by you of this program is subject to the terms
8ad49f860SLiviu Dudau  * of such GNU licence.
9ad49f860SLiviu Dudau  *
10ad49f860SLiviu Dudau  * ARM Mali DP hardware manipulation routines.
11ad49f860SLiviu Dudau  */
12ad49f860SLiviu Dudau 
13ad49f860SLiviu Dudau #ifndef __MALIDP_HW_H__
14ad49f860SLiviu Dudau #define __MALIDP_HW_H__
15ad49f860SLiviu Dudau 
16ad49f860SLiviu Dudau #include <linux/bitops.h>
17ad49f860SLiviu Dudau #include "malidp_regs.h"
18ad49f860SLiviu Dudau 
19ad49f860SLiviu Dudau struct videomode;
20ad49f860SLiviu Dudau struct clk;
21ad49f860SLiviu Dudau 
22ad49f860SLiviu Dudau /* Mali DP IP blocks */
23ad49f860SLiviu Dudau enum {
24ad49f860SLiviu Dudau 	MALIDP_DE_BLOCK = 0,
25ad49f860SLiviu Dudau 	MALIDP_SE_BLOCK,
26ad49f860SLiviu Dudau 	MALIDP_DC_BLOCK
27ad49f860SLiviu Dudau };
28ad49f860SLiviu Dudau 
29ad49f860SLiviu Dudau /* Mali DP layer IDs */
30ad49f860SLiviu Dudau enum {
31ad49f860SLiviu Dudau 	DE_VIDEO1 = BIT(0),
32ad49f860SLiviu Dudau 	DE_GRAPHICS1 = BIT(1),
33ad49f860SLiviu Dudau 	DE_GRAPHICS2 = BIT(2), /* used only in DP500 */
34ad49f860SLiviu Dudau 	DE_VIDEO2 = BIT(3),
35ad49f860SLiviu Dudau 	DE_SMART = BIT(4),
36a67bbbe2SBrian Starkey 	SE_MEMWRITE = BIT(5),
37ad49f860SLiviu Dudau };
38ad49f860SLiviu Dudau 
396211b486SBrian Starkey struct malidp_format_id {
40ad49f860SLiviu Dudau 	u32 format;		/* DRM fourcc */
41ad49f860SLiviu Dudau 	u8 layer;		/* bitmask of layers supporting it */
42ad49f860SLiviu Dudau 	u8 id;			/* used internally */
43ad49f860SLiviu Dudau };
44ad49f860SLiviu Dudau 
45ad49f860SLiviu Dudau #define MALIDP_INVALID_FORMAT_ID	0xff
46ad49f860SLiviu Dudau 
47ad49f860SLiviu Dudau /*
48ad49f860SLiviu Dudau  * hide the differences between register maps
49ad49f860SLiviu Dudau  * by using a common structure to hold the
50ad49f860SLiviu Dudau  * base register offsets
51ad49f860SLiviu Dudau  */
52ad49f860SLiviu Dudau 
53ad49f860SLiviu Dudau struct malidp_irq_map {
54ad49f860SLiviu Dudau 	u32 irq_mask;		/* mask of IRQs that can be enabled in the block */
55ad49f860SLiviu Dudau 	u32 vsync_irq;		/* IRQ bit used for signaling during VSYNC */
56613c5c7fSAlexandru Gheorghe 	u32 err_mask;		/* mask of bits that represent errors */
57ad49f860SLiviu Dudau };
58ad49f860SLiviu Dudau 
59ad49f860SLiviu Dudau struct malidp_layer {
60ad49f860SLiviu Dudau 	u16 id;			/* layer ID */
61ad49f860SLiviu Dudau 	u16 base;		/* address offset for the register bank */
62ad49f860SLiviu Dudau 	u16 ptr;		/* address offset for the pointer register */
636e810eb5SMihail Atanassov 	u16 stride_offset;	/* offset to the first stride register. */
646e810eb5SMihail Atanassov 	s16 yuv2rgb_offset;	/* offset to the YUV->RGB matrix entries */
65ad49f860SLiviu Dudau };
66ad49f860SLiviu Dudau 
6728ce675bSMihail Atanassov enum malidp_scaling_coeff_set {
6828ce675bSMihail Atanassov 	MALIDP_UPSCALING_COEFFS = 1,
6928ce675bSMihail Atanassov 	MALIDP_DOWNSCALING_1_5_COEFFS = 2,
7028ce675bSMihail Atanassov 	MALIDP_DOWNSCALING_2_COEFFS = 3,
7128ce675bSMihail Atanassov 	MALIDP_DOWNSCALING_2_75_COEFFS = 4,
7228ce675bSMihail Atanassov 	MALIDP_DOWNSCALING_4_COEFFS = 5,
7328ce675bSMihail Atanassov };
7428ce675bSMihail Atanassov 
7528ce675bSMihail Atanassov struct malidp_se_config {
7628ce675bSMihail Atanassov 	u8 scale_enable : 1;
770274e6a0SMihail Atanassov 	u8 enhancer_enable : 1;
7828ce675bSMihail Atanassov 	u8 hcoeff : 3;
7928ce675bSMihail Atanassov 	u8 vcoeff : 3;
8028ce675bSMihail Atanassov 	u8 plane_src_id;
8128ce675bSMihail Atanassov 	u16 input_w, input_h;
8228ce675bSMihail Atanassov 	u16 output_w, output_h;
8328ce675bSMihail Atanassov 	u32 h_init_phase, h_delta_phase;
8428ce675bSMihail Atanassov 	u32 v_init_phase, v_delta_phase;
8528ce675bSMihail Atanassov };
8628ce675bSMihail Atanassov 
87ad49f860SLiviu Dudau /* regmap features */
88ad49f860SLiviu Dudau #define MALIDP_REGMAP_HAS_CLEARIRQ	(1 << 0)
89ad49f860SLiviu Dudau 
90ad49f860SLiviu Dudau struct malidp_hw_regmap {
91ad49f860SLiviu Dudau 	/* address offset of the DE register bank */
92ad49f860SLiviu Dudau 	/* is always 0x0000 */
9302725d31SMihail Atanassov 	/* address offset of the DE coefficients registers */
9402725d31SMihail Atanassov 	const u16 coeffs_base;
95ad49f860SLiviu Dudau 	/* address offset of the SE registers bank */
96ad49f860SLiviu Dudau 	const u16 se_base;
97ad49f860SLiviu Dudau 	/* address offset of the DC registers bank */
98ad49f860SLiviu Dudau 	const u16 dc_base;
99ad49f860SLiviu Dudau 
100ad49f860SLiviu Dudau 	/* address offset for the output depth register */
101ad49f860SLiviu Dudau 	const u16 out_depth_base;
102ad49f860SLiviu Dudau 
103ad49f860SLiviu Dudau 	/* bitmap with register map features */
104ad49f860SLiviu Dudau 	const u8 features;
105ad49f860SLiviu Dudau 
106ad49f860SLiviu Dudau 	/* list of supported layers */
107ad49f860SLiviu Dudau 	const u8 n_layers;
108ad49f860SLiviu Dudau 	const struct malidp_layer *layers;
109ad49f860SLiviu Dudau 
110ad49f860SLiviu Dudau 	const struct malidp_irq_map de_irq_map;
111ad49f860SLiviu Dudau 	const struct malidp_irq_map se_irq_map;
112ad49f860SLiviu Dudau 	const struct malidp_irq_map dc_irq_map;
113ad49f860SLiviu Dudau 
1146211b486SBrian Starkey 	/* list of supported pixel formats for each layer */
1156211b486SBrian Starkey 	const struct malidp_format_id *pixel_formats;
1166211b486SBrian Starkey 	const u8 n_pixel_formats;
117a228062cSBrian Starkey 
118a228062cSBrian Starkey 	/* pitch alignment requirement in bytes */
119a228062cSBrian Starkey 	const u8 bus_align_bytes;
120ad49f860SLiviu Dudau };
121ad49f860SLiviu Dudau 
12283d642eeSMihail Atanassov /* device features */
12383d642eeSMihail Atanassov /* Unlike DP550/650, DP500 has 3 stride registers in its video layer. */
12483d642eeSMihail Atanassov #define MALIDP_DEVICE_LV_HAS_3_STRIDES	BIT(0)
12583d642eeSMihail Atanassov 
126a6993b21SLiviu Dudau struct malidp_hw_device;
127ad49f860SLiviu Dudau 
128a6993b21SLiviu Dudau /*
129a6993b21SLiviu Dudau  * Static structure containing hardware specific data and pointers to
130a6993b21SLiviu Dudau  * functions that behave differently between various versions of the IP.
131a6993b21SLiviu Dudau  */
132a6993b21SLiviu Dudau struct malidp_hw {
133a6993b21SLiviu Dudau 	const struct malidp_hw_regmap map;
134ad49f860SLiviu Dudau 
135ad49f860SLiviu Dudau 	/*
136ad49f860SLiviu Dudau 	 * Validate the driver instance against the hardware bits
137ad49f860SLiviu Dudau 	 */
138ad49f860SLiviu Dudau 	int (*query_hw)(struct malidp_hw_device *hwdev);
139ad49f860SLiviu Dudau 
140ad49f860SLiviu Dudau 	/*
141ad49f860SLiviu Dudau 	 * Set the hardware into config mode, ready to accept mode changes
142ad49f860SLiviu Dudau 	 */
143ad49f860SLiviu Dudau 	void (*enter_config_mode)(struct malidp_hw_device *hwdev);
144ad49f860SLiviu Dudau 
145ad49f860SLiviu Dudau 	/*
146ad49f860SLiviu Dudau 	 * Tell hardware to exit configuration mode
147ad49f860SLiviu Dudau 	 */
148ad49f860SLiviu Dudau 	void (*leave_config_mode)(struct malidp_hw_device *hwdev);
149ad49f860SLiviu Dudau 
150ad49f860SLiviu Dudau 	/*
151ad49f860SLiviu Dudau 	 * Query if hardware is in configuration mode
152ad49f860SLiviu Dudau 	 */
153ad49f860SLiviu Dudau 	bool (*in_config_mode)(struct malidp_hw_device *hwdev);
154ad49f860SLiviu Dudau 
155ad49f860SLiviu Dudau 	/*
1560735cfdfSLiviu Dudau 	 * Set/clear configuration valid flag for hardware parameters that can
1570735cfdfSLiviu Dudau 	 * be changed outside the configuration mode to the given value.
1580735cfdfSLiviu Dudau 	 * Hardware will use the new settings when config valid is set,
1590735cfdfSLiviu Dudau 	 * after the end of the current buffer scanout, and will ignore
1600735cfdfSLiviu Dudau 	 * any new values for those parameters if config valid flag is cleared
161ad49f860SLiviu Dudau 	 */
1620735cfdfSLiviu Dudau 	void (*set_config_valid)(struct malidp_hw_device *hwdev, u8 value);
163ad49f860SLiviu Dudau 
164ad49f860SLiviu Dudau 	/*
165ad49f860SLiviu Dudau 	 * Set a new mode in hardware. Requires the hardware to be in
166ad49f860SLiviu Dudau 	 * configuration mode before this function is called.
167ad49f860SLiviu Dudau 	 */
168ad49f860SLiviu Dudau 	void (*modeset)(struct malidp_hw_device *hwdev, struct videomode *m);
169ad49f860SLiviu Dudau 
170ad49f860SLiviu Dudau 	/*
171ad49f860SLiviu Dudau 	 * Calculate the required rotation memory given the active area
172ad49f860SLiviu Dudau 	 * and the buffer format.
173ad49f860SLiviu Dudau 	 */
174ad49f860SLiviu Dudau 	int (*rotmem_required)(struct malidp_hw_device *hwdev, u16 w, u16 h, u32 fmt);
175ad49f860SLiviu Dudau 
17628ce675bSMihail Atanassov 	int (*se_set_scaling_coeffs)(struct malidp_hw_device *hwdev,
17728ce675bSMihail Atanassov 				     struct malidp_se_config *se_config,
17828ce675bSMihail Atanassov 				     struct malidp_se_config *old_config);
17928ce675bSMihail Atanassov 
180c2e7f82dSMihail Atanassov 	long (*se_calc_mclk)(struct malidp_hw_device *hwdev,
181c2e7f82dSMihail Atanassov 			     struct malidp_se_config *se_config,
182c2e7f82dSMihail Atanassov 			     struct videomode *vm);
1831cb3cbe7SLiviu Dudau 	/*
184846c87a0SLiviu Dudau 	 * Enable writing to memory the content of the next frame
185846c87a0SLiviu Dudau 	 * @param hwdev - malidp_hw_device structure containing the HW description
186846c87a0SLiviu Dudau 	 * @param addrs - array of addresses for each plane
187846c87a0SLiviu Dudau 	 * @param pitches - array of pitches for each plane
188846c87a0SLiviu Dudau 	 * @param num_planes - number of planes to be written
189846c87a0SLiviu Dudau 	 * @param w - width of the output frame
190846c87a0SLiviu Dudau 	 * @param h - height of the output frame
191846c87a0SLiviu Dudau 	 * @param fmt_id - internal format ID of output buffer
192846c87a0SLiviu Dudau 	 */
193846c87a0SLiviu Dudau 	int (*enable_memwrite)(struct malidp_hw_device *hwdev, dma_addr_t *addrs,
194846c87a0SLiviu Dudau 			       s32 *pitches, int num_planes, u16 w, u16 h, u32 fmt_id);
195846c87a0SLiviu Dudau 
196846c87a0SLiviu Dudau 	/*
197846c87a0SLiviu Dudau 	 * Disable the writing to memory of the next frame's content.
198846c87a0SLiviu Dudau 	 */
199846c87a0SLiviu Dudau 	void (*disable_memwrite)(struct malidp_hw_device *hwdev);
200c2e7f82dSMihail Atanassov 
201ad49f860SLiviu Dudau 	u8 features;
202ad49f860SLiviu Dudau };
203ad49f860SLiviu Dudau 
204ad49f860SLiviu Dudau /* Supported variants of the hardware */
205ad49f860SLiviu Dudau enum {
206ad49f860SLiviu Dudau 	MALIDP_500 = 0,
207ad49f860SLiviu Dudau 	MALIDP_550,
208ad49f860SLiviu Dudau 	MALIDP_650,
209ad49f860SLiviu Dudau 	/* keep the next entry last */
210ad49f860SLiviu Dudau 	MALIDP_MAX_DEVICES
211ad49f860SLiviu Dudau };
212ad49f860SLiviu Dudau 
213a6993b21SLiviu Dudau extern const struct malidp_hw malidp_device[MALIDP_MAX_DEVICES];
214a6993b21SLiviu Dudau 
215a6993b21SLiviu Dudau /*
216a6993b21SLiviu Dudau  * Structure used by the driver during runtime operation.
217a6993b21SLiviu Dudau  */
218a6993b21SLiviu Dudau struct malidp_hw_device {
219a6993b21SLiviu Dudau 	struct malidp_hw *hw;
220a6993b21SLiviu Dudau 	void __iomem *regs;
221a6993b21SLiviu Dudau 
222a6993b21SLiviu Dudau 	/* APB clock */
223a6993b21SLiviu Dudau 	struct clk *pclk;
224a6993b21SLiviu Dudau 	/* AXI clock */
225a6993b21SLiviu Dudau 	struct clk *aclk;
226a6993b21SLiviu Dudau 	/* main clock for display core */
227a6993b21SLiviu Dudau 	struct clk *mclk;
228a6993b21SLiviu Dudau 	/* pixel clock for display core */
229a6993b21SLiviu Dudau 	struct clk *pxlclk;
230a6993b21SLiviu Dudau 
231a6993b21SLiviu Dudau 	u8 min_line_size;
232a6993b21SLiviu Dudau 	u16 max_line_size;
233a6993b21SLiviu Dudau 
234a6993b21SLiviu Dudau 	/* track the device PM state */
235a6993b21SLiviu Dudau 	bool pm_suspended;
236a6993b21SLiviu Dudau 
2371cb3cbe7SLiviu Dudau 	/* track the SE memory writeback state */
2381cb3cbe7SLiviu Dudau 	u8 mw_state;
2391cb3cbe7SLiviu Dudau 
240a6993b21SLiviu Dudau 	/* size of memory used for rotating layers, up to two banks available */
241a6993b21SLiviu Dudau 	u32 rotation_memory[2];
242a6993b21SLiviu Dudau };
243ad49f860SLiviu Dudau 
244ad49f860SLiviu Dudau static inline u32 malidp_hw_read(struct malidp_hw_device *hwdev, u32 reg)
245ad49f860SLiviu Dudau {
24685f64218SLiviu Dudau 	WARN_ON(hwdev->pm_suspended);
247ad49f860SLiviu Dudau 	return readl(hwdev->regs + reg);
248ad49f860SLiviu Dudau }
249ad49f860SLiviu Dudau 
250ad49f860SLiviu Dudau static inline void malidp_hw_write(struct malidp_hw_device *hwdev,
251ad49f860SLiviu Dudau 				   u32 value, u32 reg)
252ad49f860SLiviu Dudau {
25385f64218SLiviu Dudau 	WARN_ON(hwdev->pm_suspended);
254ad49f860SLiviu Dudau 	writel(value, hwdev->regs + reg);
255ad49f860SLiviu Dudau }
256ad49f860SLiviu Dudau 
257ad49f860SLiviu Dudau static inline void malidp_hw_setbits(struct malidp_hw_device *hwdev,
258ad49f860SLiviu Dudau 				     u32 mask, u32 reg)
259ad49f860SLiviu Dudau {
260ad49f860SLiviu Dudau 	u32 data = malidp_hw_read(hwdev, reg);
261ad49f860SLiviu Dudau 
262ad49f860SLiviu Dudau 	data |= mask;
263ad49f860SLiviu Dudau 	malidp_hw_write(hwdev, data, reg);
264ad49f860SLiviu Dudau }
265ad49f860SLiviu Dudau 
266ad49f860SLiviu Dudau static inline void malidp_hw_clearbits(struct malidp_hw_device *hwdev,
267ad49f860SLiviu Dudau 				       u32 mask, u32 reg)
268ad49f860SLiviu Dudau {
269ad49f860SLiviu Dudau 	u32 data = malidp_hw_read(hwdev, reg);
270ad49f860SLiviu Dudau 
271ad49f860SLiviu Dudau 	data &= ~mask;
272ad49f860SLiviu Dudau 	malidp_hw_write(hwdev, data, reg);
273ad49f860SLiviu Dudau }
274ad49f860SLiviu Dudau 
275ad49f860SLiviu Dudau static inline u32 malidp_get_block_base(struct malidp_hw_device *hwdev,
276ad49f860SLiviu Dudau 					u8 block)
277ad49f860SLiviu Dudau {
278ad49f860SLiviu Dudau 	switch (block) {
279ad49f860SLiviu Dudau 	case MALIDP_SE_BLOCK:
280a6993b21SLiviu Dudau 		return hwdev->hw->map.se_base;
281ad49f860SLiviu Dudau 	case MALIDP_DC_BLOCK:
282a6993b21SLiviu Dudau 		return hwdev->hw->map.dc_base;
283ad49f860SLiviu Dudau 	}
284ad49f860SLiviu Dudau 
285ad49f860SLiviu Dudau 	return 0;
286ad49f860SLiviu Dudau }
287ad49f860SLiviu Dudau 
288ad49f860SLiviu Dudau static inline void malidp_hw_disable_irq(struct malidp_hw_device *hwdev,
289ad49f860SLiviu Dudau 					 u8 block, u32 irq)
290ad49f860SLiviu Dudau {
291ad49f860SLiviu Dudau 	u32 base = malidp_get_block_base(hwdev, block);
292ad49f860SLiviu Dudau 
293ad49f860SLiviu Dudau 	malidp_hw_clearbits(hwdev, irq, base + MALIDP_REG_MASKIRQ);
294ad49f860SLiviu Dudau }
295ad49f860SLiviu Dudau 
296ad49f860SLiviu Dudau static inline void malidp_hw_enable_irq(struct malidp_hw_device *hwdev,
297ad49f860SLiviu Dudau 					u8 block, u32 irq)
298ad49f860SLiviu Dudau {
299ad49f860SLiviu Dudau 	u32 base = malidp_get_block_base(hwdev, block);
300ad49f860SLiviu Dudau 
301ad49f860SLiviu Dudau 	malidp_hw_setbits(hwdev, irq, base + MALIDP_REG_MASKIRQ);
302ad49f860SLiviu Dudau }
303ad49f860SLiviu Dudau 
304ad49f860SLiviu Dudau int malidp_de_irq_init(struct drm_device *drm, int irq);
30562862cfbSAyan Kumar Halder void malidp_de_irq_fini(struct malidp_hw_device *hwdev);
306ad49f860SLiviu Dudau int malidp_se_irq_init(struct drm_device *drm, int irq);
30762862cfbSAyan Kumar Halder void malidp_se_irq_fini(struct malidp_hw_device *hwdev);
308ad49f860SLiviu Dudau 
309ad49f860SLiviu Dudau u8 malidp_hw_get_format_id(const struct malidp_hw_regmap *map,
310ad49f860SLiviu Dudau 			   u8 layer_id, u32 format);
311ad49f860SLiviu Dudau 
312fcad73b9SLiviu Dudau static inline u8 malidp_hw_get_pitch_align(struct malidp_hw_device *hwdev, bool rotated)
313a228062cSBrian Starkey {
314fcad73b9SLiviu Dudau 	/*
315fcad73b9SLiviu Dudau 	 * only hardware that cannot do 8 bytes bus alignments have further
316fcad73b9SLiviu Dudau 	 * constraints on rotated planes
317fcad73b9SLiviu Dudau 	 */
318fcad73b9SLiviu Dudau 	if (hwdev->hw->map.bus_align_bytes == 8)
319fcad73b9SLiviu Dudau 		return 8;
320fcad73b9SLiviu Dudau 	else
321fcad73b9SLiviu Dudau 		return hwdev->hw->map.bus_align_bytes << (rotated ? 2 : 0);
322a228062cSBrian Starkey }
323a228062cSBrian Starkey 
32428ce675bSMihail Atanassov /* U16.16 */
32528ce675bSMihail Atanassov #define FP_1_00000	0x00010000	/* 1.0 */
32628ce675bSMihail Atanassov #define FP_0_66667	0x0000AAAA	/* 0.6667 = 1/1.5 */
32728ce675bSMihail Atanassov #define FP_0_50000	0x00008000	/* 0.5 = 1/2 */
32828ce675bSMihail Atanassov #define FP_0_36363	0x00005D17	/* 0.36363 = 1/2.75 */
32928ce675bSMihail Atanassov #define FP_0_25000	0x00004000	/* 0.25 = 1/4 */
33028ce675bSMihail Atanassov 
33128ce675bSMihail Atanassov static inline enum malidp_scaling_coeff_set
33228ce675bSMihail Atanassov malidp_se_select_coeffs(u32 upscale_factor)
33328ce675bSMihail Atanassov {
33428ce675bSMihail Atanassov 	return (upscale_factor >= FP_1_00000) ? MALIDP_UPSCALING_COEFFS :
33528ce675bSMihail Atanassov 	       (upscale_factor >= FP_0_66667) ? MALIDP_DOWNSCALING_1_5_COEFFS :
33628ce675bSMihail Atanassov 	       (upscale_factor >= FP_0_50000) ? MALIDP_DOWNSCALING_2_COEFFS :
33728ce675bSMihail Atanassov 	       (upscale_factor >= FP_0_36363) ? MALIDP_DOWNSCALING_2_75_COEFFS :
33828ce675bSMihail Atanassov 	       MALIDP_DOWNSCALING_4_COEFFS;
33928ce675bSMihail Atanassov }
34028ce675bSMihail Atanassov 
34128ce675bSMihail Atanassov #undef FP_0_25000
34228ce675bSMihail Atanassov #undef FP_0_36363
34328ce675bSMihail Atanassov #undef FP_0_50000
34428ce675bSMihail Atanassov #undef FP_0_66667
34528ce675bSMihail Atanassov #undef FP_1_00000
3460274e6a0SMihail Atanassov 
3470274e6a0SMihail Atanassov static inline void malidp_se_set_enh_coeffs(struct malidp_hw_device *hwdev)
3480274e6a0SMihail Atanassov {
3490274e6a0SMihail Atanassov 	static const s32 enhancer_coeffs[] = {
3500274e6a0SMihail Atanassov 		-8, -8, -8, -8, 128, -8, -8, -8, -8
3510274e6a0SMihail Atanassov 	};
3520274e6a0SMihail Atanassov 	u32 val = MALIDP_SE_SET_ENH_LIMIT_LOW(MALIDP_SE_ENH_LOW_LEVEL) |
3530274e6a0SMihail Atanassov 		  MALIDP_SE_SET_ENH_LIMIT_HIGH(MALIDP_SE_ENH_HIGH_LEVEL);
354a6993b21SLiviu Dudau 	u32 image_enh = hwdev->hw->map.se_base +
355a6993b21SLiviu Dudau 			((hwdev->hw->map.features & MALIDP_REGMAP_HAS_CLEARIRQ) ?
3560274e6a0SMihail Atanassov 			 0x10 : 0xC) + MALIDP_SE_IMAGE_ENH;
3570274e6a0SMihail Atanassov 	u32 enh_coeffs = image_enh + MALIDP_SE_ENH_COEFF0;
3580274e6a0SMihail Atanassov 	int i;
3590274e6a0SMihail Atanassov 
3600274e6a0SMihail Atanassov 	malidp_hw_write(hwdev, val, image_enh);
3610274e6a0SMihail Atanassov 	for (i = 0; i < ARRAY_SIZE(enhancer_coeffs); ++i)
3620274e6a0SMihail Atanassov 		malidp_hw_write(hwdev, enhancer_coeffs[i], enh_coeffs + i * 4);
3630274e6a0SMihail Atanassov }
3640274e6a0SMihail Atanassov 
365ad49f860SLiviu Dudau /*
366ad49f860SLiviu Dudau  * background color components are defined as 12bits values,
367ad49f860SLiviu Dudau  * they will be shifted right when stored on hardware that
368ad49f860SLiviu Dudau  * supports only 8bits per channel
369ad49f860SLiviu Dudau  */
370ad49f860SLiviu Dudau #define MALIDP_BGND_COLOR_R		0x000
371ad49f860SLiviu Dudau #define MALIDP_BGND_COLOR_G		0x000
372ad49f860SLiviu Dudau #define MALIDP_BGND_COLOR_B		0x000
373ad49f860SLiviu Dudau 
3746954f245SMihail Atanassov #define MALIDP_COLORADJ_NUM_COEFFS	12
37502725d31SMihail Atanassov #define MALIDP_COEFFTAB_NUM_COEFFS	64
37602725d31SMihail Atanassov 
37702725d31SMihail Atanassov #define MALIDP_GAMMA_LUT_SIZE		4096
37802725d31SMihail Atanassov 
379ad49f860SLiviu Dudau #endif  /* __MALIDP_HW_H__ */
380