1 /* 2 * Copyright 2019 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 * Authors: AMD 23 * 24 */ 25 26 #include "dc_bios_types.h" 27 #include "hw_shared.h" 28 #include "dcn30/dcn30_afmt.h" 29 #include "dcn31_afmt.h" 30 #include "reg_helper.h" 31 #include "dc/dc.h" 32 33 #define DC_LOGGER \ 34 afmt31->base.ctx->logger 35 36 #define REG(reg)\ 37 (afmt31->regs->reg) 38 39 #undef FN 40 #define FN(reg_name, field_name) \ 41 afmt31->afmt_shift->field_name, afmt31->afmt_mask->field_name 42 43 44 #define CTX \ 45 afmt31->base.ctx 46 47 static struct afmt_funcs dcn31_afmt_funcs = { 48 .setup_hdmi_audio = afmt3_setup_hdmi_audio, 49 .se_audio_setup = afmt3_se_audio_setup, 50 .audio_mute_control = afmt3_audio_mute_control, 51 .audio_info_immediate_update = afmt3_audio_info_immediate_update, 52 .setup_dp_audio = afmt3_setup_dp_audio, 53 .afmt_powerdown = afmt31_powerdown, 54 .afmt_poweron = afmt31_poweron 55 }; 56 57 void afmt31_powerdown(struct afmt *afmt) 58 { 59 struct dcn31_afmt *afmt31 = DCN31_AFMT_FROM_AFMT(afmt); 60 61 if (afmt->ctx->dc->debug.enable_mem_low_power.bits.afmt == false) 62 return; 63 64 REG_UPDATE_2(AFMT_MEM_PWR, AFMT_MEM_PWR_DIS, 0, AFMT_MEM_PWR_FORCE, 1); 65 } 66 67 void afmt31_poweron(struct afmt *afmt) 68 { 69 struct dcn31_afmt *afmt31 = DCN31_AFMT_FROM_AFMT(afmt); 70 71 if (afmt->ctx->dc->debug.enable_mem_low_power.bits.afmt == false) 72 return; 73 74 REG_UPDATE_2(AFMT_MEM_PWR, AFMT_MEM_PWR_DIS, 1, AFMT_MEM_PWR_FORCE, 0); 75 } 76 77 void afmt31_construct(struct dcn31_afmt *afmt31, 78 struct dc_context *ctx, 79 uint32_t inst, 80 const struct dcn31_afmt_registers *afmt_regs, 81 const struct dcn31_afmt_shift *afmt_shift, 82 const struct dcn31_afmt_mask *afmt_mask) 83 { 84 afmt31->base.ctx = ctx; 85 86 afmt31->base.inst = inst; 87 afmt31->base.funcs = &dcn31_afmt_funcs; 88 89 afmt31->regs = afmt_regs; 90 afmt31->afmt_shift = afmt_shift; 91 afmt31->afmt_mask = afmt_mask; 92 } 93