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 #include "dm_services.h"
2770ccab60SHarry Wentland #include "dcn10_ipp.h"
2870ccab60SHarry Wentland #include "reg_helper.h"
2970ccab60SHarry Wentland 
3070ccab60SHarry Wentland #define REG(reg) \
3170ccab60SHarry Wentland 	(ippn10->regs->reg)
3270ccab60SHarry Wentland 
3370ccab60SHarry Wentland #undef FN
3470ccab60SHarry Wentland #define FN(reg_name, field_name) \
3570ccab60SHarry Wentland 	ippn10->ipp_shift->field_name, ippn10->ipp_mask->field_name
3670ccab60SHarry Wentland 
3770ccab60SHarry Wentland #define CTX \
3870ccab60SHarry Wentland 	ippn10->base.ctx
3970ccab60SHarry Wentland 
4070ccab60SHarry Wentland /*****************************************/
4170ccab60SHarry Wentland /* Constructor, Destructor               */
4270ccab60SHarry Wentland /*****************************************/
4370ccab60SHarry Wentland 
dcn10_ipp_destroy(struct input_pixel_processor ** ipp)4470ccab60SHarry Wentland static void dcn10_ipp_destroy(struct input_pixel_processor **ipp)
4570ccab60SHarry Wentland {
462004f45eSHarry Wentland 	kfree(TO_DCN10_IPP(*ipp));
4770ccab60SHarry Wentland 	*ipp = NULL;
4870ccab60SHarry Wentland }
4970ccab60SHarry Wentland 
5070ccab60SHarry Wentland static const struct ipp_funcs dcn10_ipp_funcs = {
5170ccab60SHarry Wentland 	.ipp_destroy			= dcn10_ipp_destroy
5270ccab60SHarry Wentland };
5370ccab60SHarry Wentland 
5483421f32SHarry Wentland static const struct ipp_funcs dcn20_ipp_funcs = {
5583421f32SHarry Wentland 	.ipp_destroy			= dcn10_ipp_destroy
5683421f32SHarry Wentland };
5783421f32SHarry Wentland 
dcn10_ipp_construct(struct dcn10_ipp * ippn10,struct dc_context * ctx,int inst,const struct dcn10_ipp_registers * regs,const struct dcn10_ipp_shift * ipp_shift,const struct dcn10_ipp_mask * ipp_mask)5870ccab60SHarry Wentland void dcn10_ipp_construct(
5970ccab60SHarry Wentland 	struct dcn10_ipp *ippn10,
6070ccab60SHarry Wentland 	struct dc_context *ctx,
6170ccab60SHarry Wentland 	int inst,
6270ccab60SHarry Wentland 	const struct dcn10_ipp_registers *regs,
6370ccab60SHarry Wentland 	const struct dcn10_ipp_shift *ipp_shift,
6470ccab60SHarry Wentland 	const struct dcn10_ipp_mask *ipp_mask)
6570ccab60SHarry Wentland {
6670ccab60SHarry Wentland 	ippn10->base.ctx = ctx;
6770ccab60SHarry Wentland 	ippn10->base.inst = inst;
6870ccab60SHarry Wentland 	ippn10->base.funcs = &dcn10_ipp_funcs;
6970ccab60SHarry Wentland 
7070ccab60SHarry Wentland 	ippn10->regs = regs;
7170ccab60SHarry Wentland 	ippn10->ipp_shift = ipp_shift;
7270ccab60SHarry Wentland 	ippn10->ipp_mask = ipp_mask;
7370ccab60SHarry Wentland }
74a3ac9dadSDmytro Laktyushkin 
dcn20_ipp_construct(struct dcn10_ipp * ippn10,struct dc_context * ctx,int inst,const struct dcn10_ipp_registers * regs,const struct dcn10_ipp_shift * ipp_shift,const struct dcn10_ipp_mask * ipp_mask)7583421f32SHarry Wentland void dcn20_ipp_construct(
7683421f32SHarry Wentland 	struct dcn10_ipp *ippn10,
7783421f32SHarry Wentland 	struct dc_context *ctx,
7883421f32SHarry Wentland 	int inst,
7983421f32SHarry Wentland 	const struct dcn10_ipp_registers *regs,
8083421f32SHarry Wentland 	const struct dcn10_ipp_shift *ipp_shift,
8183421f32SHarry Wentland 	const struct dcn10_ipp_mask *ipp_mask)
8283421f32SHarry Wentland {
8383421f32SHarry Wentland 	ippn10->base.ctx = ctx;
8483421f32SHarry Wentland 	ippn10->base.inst = inst;
8583421f32SHarry Wentland 	ippn10->base.funcs = &dcn20_ipp_funcs;
8683421f32SHarry Wentland 
8783421f32SHarry Wentland 	ippn10->regs = regs;
8883421f32SHarry Wentland 	ippn10->ipp_shift = ipp_shift;
8983421f32SHarry Wentland 	ippn10->ipp_mask = ipp_mask;
9083421f32SHarry Wentland }
91