170ccab60SHarry Wentland /*
270ccab60SHarry Wentland  * Copyright 2017 Advanced Micro Devices, Inc.
370ccab60SHarry Wentland  *
470ccab60SHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
570ccab60SHarry Wentland  * copy of this software and associated documentation files (the "Software"),
670ccab60SHarry Wentland  * to deal in the Software without restriction, including without limitation
770ccab60SHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
870ccab60SHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
970ccab60SHarry Wentland  * Software is furnished to do so, subject to the following conditions:
1070ccab60SHarry Wentland  *
1170ccab60SHarry Wentland  * The above copyright notice and this permission notice shall be included in
1270ccab60SHarry Wentland  * all copies or substantial portions of the Software.
1370ccab60SHarry Wentland  *
1470ccab60SHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1570ccab60SHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1670ccab60SHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1770ccab60SHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1870ccab60SHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1970ccab60SHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2070ccab60SHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
2170ccab60SHarry Wentland  *
2270ccab60SHarry Wentland  * Authors: AMD
2370ccab60SHarry Wentland  *
2470ccab60SHarry Wentland  */
2570ccab60SHarry Wentland 
2670ccab60SHarry Wentland #ifndef _DCN10_IPP_H_
2770ccab60SHarry Wentland #define _DCN10_IPP_H_
2870ccab60SHarry Wentland 
2970ccab60SHarry Wentland #include "ipp.h"
3070ccab60SHarry Wentland 
3170ccab60SHarry Wentland #define TO_DCN10_IPP(ipp)\
3270ccab60SHarry Wentland 	container_of(ipp, struct dcn10_ipp, base)
3370ccab60SHarry Wentland 
3435ce37d6SDmytro Laktyushkin #define IPP_REG_LIST_DCN(id) \
3535ce37d6SDmytro Laktyushkin 	SRI(FORMAT_CONTROL, CNVC_CFG, id), \
3670ccab60SHarry Wentland 	SRI(DPP_CONTROL, DPP_TOP, id), \
3770ccab60SHarry Wentland 	SRI(CNVC_SURFACE_PIXEL_FORMAT, CNVC_CFG, id), \
3870ccab60SHarry Wentland 	SRI(CURSOR0_CONTROL, CNVC_CUR, id), \
3970ccab60SHarry Wentland 	SRI(CURSOR0_COLOR0, CNVC_CUR, id), \
4035ce37d6SDmytro Laktyushkin 	SRI(CURSOR0_COLOR1, CNVC_CUR, id)
4135ce37d6SDmytro Laktyushkin 
4235ce37d6SDmytro Laktyushkin #define IPP_REG_LIST_DCN10(id) \
4335ce37d6SDmytro Laktyushkin 	IPP_REG_LIST_DCN(id), \
449b1c9b4cSDmytro Laktyushkin 	SRI(CURSOR_SETTINS, HUBPREQ, id), \
4570ccab60SHarry Wentland 	SRI(CURSOR_SURFACE_ADDRESS_HIGH, CURSOR, id), \
4670ccab60SHarry Wentland 	SRI(CURSOR_SURFACE_ADDRESS, CURSOR, id), \
4770ccab60SHarry Wentland 	SRI(CURSOR_SIZE, CURSOR, id), \
4870ccab60SHarry Wentland 	SRI(CURSOR_CONTROL, CURSOR, id), \
4970ccab60SHarry Wentland 	SRI(CURSOR_POSITION, CURSOR, id), \
5070ccab60SHarry Wentland 	SRI(CURSOR_HOT_SPOT, CURSOR, id), \
5170ccab60SHarry Wentland 	SRI(CURSOR_DST_OFFSET, CURSOR, id)
5270ccab60SHarry Wentland 
53e9475143Spana #define CURSOR0_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT	0x4
54e9475143Spana #define CURSOR0_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK		0x00000010L
55e9475143Spana #define CURSOR1_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT	0x4
56e9475143Spana #define CURSOR1_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK		0x00000010L
57e9475143Spana #define CURSOR2_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT	0x4
58e9475143Spana #define CURSOR2_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK		0x00000010L
59e9475143Spana #define CURSOR3_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT	0x4
60e9475143Spana #define CURSOR3_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK		0x00000010L
61e9475143Spana 
6270ccab60SHarry Wentland #define IPP_SF(reg_name, field_name, post_fix)\
6370ccab60SHarry Wentland 	.field_name = reg_name ## __ ## field_name ## post_fix
6470ccab60SHarry Wentland 
6535ce37d6SDmytro Laktyushkin #define IPP_MASK_SH_LIST_DCN(mask_sh) \
6635ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CFG0_CNVC_SURFACE_PIXEL_FORMAT, CNVC_SURFACE_PIXEL_FORMAT, mask_sh), \
6735ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CFG0_FORMAT_CONTROL, CNVC_BYPASS, mask_sh), \
6835ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CFG0_FORMAT_CONTROL, ALPHA_EN, mask_sh), \
6935ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CFG0_FORMAT_CONTROL, FORMAT_EXPANSION_MODE, mask_sh), \
7035ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CUR0_CURSOR0_CONTROL, CUR0_MODE, mask_sh), \
7135ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CUR0_CURSOR0_COLOR0, CUR0_COLOR0, mask_sh), \
7235ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CUR0_CURSOR0_COLOR1, CUR0_COLOR1, mask_sh), \
7335ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CUR0_CURSOR0_CONTROL, CUR0_EXPANSION_MODE, mask_sh), \
7435ce37d6SDmytro Laktyushkin 	IPP_SF(CNVC_CUR0_CURSOR0_CONTROL, CUR0_ENABLE, mask_sh)
7535ce37d6SDmytro Laktyushkin 
7635ce37d6SDmytro Laktyushkin #define IPP_MASK_SH_LIST_DCN10(mask_sh) \
7735ce37d6SDmytro Laktyushkin 	IPP_MASK_SH_LIST_DCN(mask_sh),\
789b1c9b4cSDmytro Laktyushkin 	IPP_SF(HUBPREQ0_CURSOR_SETTINS, CURSOR0_DST_Y_OFFSET, mask_sh), \
799b1c9b4cSDmytro Laktyushkin 	IPP_SF(HUBPREQ0_CURSOR_SETTINS, CURSOR0_CHUNK_HDL_ADJUST, mask_sh), \
8070ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_SURFACE_ADDRESS_HIGH, CURSOR_SURFACE_ADDRESS_HIGH, mask_sh), \
8170ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_SURFACE_ADDRESS, CURSOR_SURFACE_ADDRESS, mask_sh), \
8270ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_SIZE, CURSOR_WIDTH, mask_sh), \
8370ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_SIZE, CURSOR_HEIGHT, mask_sh), \
8470ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_CONTROL, CURSOR_MODE, mask_sh), \
85e9475143Spana 	IPP_SF(CURSOR0_CURSOR_CONTROL, CURSOR_2X_MAGNIFY, mask_sh), \
8670ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_CONTROL, CURSOR_PITCH, mask_sh), \
8770ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_CONTROL, CURSOR_LINES_PER_CHUNK, mask_sh), \
8870ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_CONTROL, CURSOR_ENABLE, mask_sh), \
8970ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_POSITION, CURSOR_X_POSITION, mask_sh), \
9070ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_POSITION, CURSOR_Y_POSITION, mask_sh), \
9170ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_X, mask_sh), \
9270ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_HOT_SPOT, CURSOR_HOT_SPOT_Y, mask_sh), \
9370ccab60SHarry Wentland 	IPP_SF(CURSOR0_CURSOR_DST_OFFSET, CURSOR_DST_X_OFFSET, mask_sh), \
9470ccab60SHarry Wentland 	IPP_SF(CNVC_CFG0_FORMAT_CONTROL, OUTPUT_FP, mask_sh)
9570ccab60SHarry Wentland 
9670ccab60SHarry Wentland #define IPP_DCN10_REG_FIELD_LIST(type) \
9770ccab60SHarry Wentland 	type CNVC_SURFACE_PIXEL_FORMAT; \
9870ccab60SHarry Wentland 	type CNVC_BYPASS; \
9970ccab60SHarry Wentland 	type ALPHA_EN; \
10070ccab60SHarry Wentland 	type FORMAT_EXPANSION_MODE; \
10170ccab60SHarry Wentland 	type CURSOR0_DST_Y_OFFSET; \
10270ccab60SHarry Wentland 	type CURSOR0_CHUNK_HDL_ADJUST; \
10370ccab60SHarry Wentland 	type CUR0_MODE; \
10470ccab60SHarry Wentland 	type CUR0_COLOR0; \
10570ccab60SHarry Wentland 	type CUR0_COLOR1; \
10670ccab60SHarry Wentland 	type CUR0_EXPANSION_MODE; \
10770ccab60SHarry Wentland 	type CURSOR_SURFACE_ADDRESS_HIGH; \
10870ccab60SHarry Wentland 	type CURSOR_SURFACE_ADDRESS; \
10970ccab60SHarry Wentland 	type CURSOR_WIDTH; \
11070ccab60SHarry Wentland 	type CURSOR_HEIGHT; \
11170ccab60SHarry Wentland 	type CURSOR_MODE; \
112e9475143Spana 	type CURSOR_2X_MAGNIFY; \
11370ccab60SHarry Wentland 	type CURSOR_PITCH; \
11470ccab60SHarry Wentland 	type CURSOR_LINES_PER_CHUNK; \
11570ccab60SHarry Wentland 	type CURSOR_ENABLE; \
11670ccab60SHarry Wentland 	type CUR0_ENABLE; \
11770ccab60SHarry Wentland 	type CURSOR_X_POSITION; \
11870ccab60SHarry Wentland 	type CURSOR_Y_POSITION; \
11970ccab60SHarry Wentland 	type CURSOR_HOT_SPOT_X; \
12070ccab60SHarry Wentland 	type CURSOR_HOT_SPOT_Y; \
12170ccab60SHarry Wentland 	type CURSOR_DST_X_OFFSET; \
12270ccab60SHarry Wentland 	type OUTPUT_FP
12370ccab60SHarry Wentland 
12470ccab60SHarry Wentland struct dcn10_ipp_shift {
12570ccab60SHarry Wentland 	IPP_DCN10_REG_FIELD_LIST(uint8_t);
12670ccab60SHarry Wentland };
12770ccab60SHarry Wentland 
12870ccab60SHarry Wentland struct dcn10_ipp_mask {
12970ccab60SHarry Wentland 	IPP_DCN10_REG_FIELD_LIST(uint32_t);
13070ccab60SHarry Wentland };
13170ccab60SHarry Wentland 
13270ccab60SHarry Wentland struct dcn10_ipp_registers {
13370ccab60SHarry Wentland 	uint32_t DPP_CONTROL;
13470ccab60SHarry Wentland 	uint32_t CURSOR_SETTINS;
1359b1c9b4cSDmytro Laktyushkin 	uint32_t CURSOR_SETTINGS;
13670ccab60SHarry Wentland 	uint32_t CNVC_SURFACE_PIXEL_FORMAT;
13770ccab60SHarry Wentland 	uint32_t CURSOR0_CONTROL;
13870ccab60SHarry Wentland 	uint32_t CURSOR0_COLOR0;
13970ccab60SHarry Wentland 	uint32_t CURSOR0_COLOR1;
14070ccab60SHarry Wentland 	uint32_t FORMAT_CONTROL;
14170ccab60SHarry Wentland 	uint32_t CURSOR_SURFACE_ADDRESS_HIGH;
14270ccab60SHarry Wentland 	uint32_t CURSOR_SURFACE_ADDRESS;
14370ccab60SHarry Wentland 	uint32_t CURSOR_SIZE;
14470ccab60SHarry Wentland 	uint32_t CURSOR_CONTROL;
14570ccab60SHarry Wentland 	uint32_t CURSOR_POSITION;
14670ccab60SHarry Wentland 	uint32_t CURSOR_HOT_SPOT;
14770ccab60SHarry Wentland 	uint32_t CURSOR_DST_OFFSET;
14870ccab60SHarry Wentland };
14970ccab60SHarry Wentland 
15070ccab60SHarry Wentland struct dcn10_ipp {
15170ccab60SHarry Wentland 	struct input_pixel_processor base;
15270ccab60SHarry Wentland 
15370ccab60SHarry Wentland 	const struct dcn10_ipp_registers *regs;
15470ccab60SHarry Wentland 	const struct dcn10_ipp_shift *ipp_shift;
15570ccab60SHarry Wentland 	const struct dcn10_ipp_mask *ipp_mask;
15670ccab60SHarry Wentland 
15770ccab60SHarry Wentland 	struct dc_cursor_attributes curs_attr;
15870ccab60SHarry Wentland };
15970ccab60SHarry Wentland 
16070ccab60SHarry Wentland void dcn10_ipp_construct(struct dcn10_ipp *ippn10,
16170ccab60SHarry Wentland 	struct dc_context *ctx,
16270ccab60SHarry Wentland 	int inst,
16370ccab60SHarry Wentland 	const struct dcn10_ipp_registers *regs,
16470ccab60SHarry Wentland 	const struct dcn10_ipp_shift *ipp_shift,
16570ccab60SHarry Wentland 	const struct dcn10_ipp_mask *ipp_mask);
16670ccab60SHarry Wentland 
16770ccab60SHarry Wentland #endif /* _DCN10_IPP_H_ */
168