Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2019 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  *  and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 #include "dc_bios_types.h"
0027 #include "hw_shared.h"
0028 #include "dcn30/dcn30_afmt.h"
0029 #include "dcn31_afmt.h"
0030 #include "reg_helper.h"
0031 #include "dc/dc.h"
0032 
0033 #define DC_LOGGER \
0034         afmt31->base.ctx->logger
0035 
0036 #define REG(reg)\
0037     (afmt31->regs->reg)
0038 
0039 #undef FN
0040 #define FN(reg_name, field_name) \
0041     afmt31->afmt_shift->field_name, afmt31->afmt_mask->field_name
0042 
0043 
0044 #define CTX \
0045     afmt31->base.ctx
0046 
0047 static struct afmt_funcs dcn31_afmt_funcs = {
0048     .setup_hdmi_audio       = afmt3_setup_hdmi_audio,
0049     .se_audio_setup         = afmt3_se_audio_setup,
0050     .audio_mute_control     = afmt3_audio_mute_control,
0051     .audio_info_immediate_update    = afmt3_audio_info_immediate_update,
0052     .setup_dp_audio         = afmt3_setup_dp_audio,
0053     .afmt_powerdown         = afmt31_powerdown,
0054     .afmt_poweron           = afmt31_poweron
0055 };
0056 
0057 void afmt31_powerdown(struct afmt *afmt)
0058 {
0059     struct dcn31_afmt *afmt31 = DCN31_AFMT_FROM_AFMT(afmt);
0060 
0061     if (afmt->ctx->dc->debug.enable_mem_low_power.bits.afmt == false)
0062         return;
0063 
0064     REG_UPDATE_2(AFMT_MEM_PWR, AFMT_MEM_PWR_DIS, 0, AFMT_MEM_PWR_FORCE, 1);
0065 }
0066 
0067 void afmt31_poweron(struct afmt *afmt)
0068 {
0069     struct dcn31_afmt *afmt31 = DCN31_AFMT_FROM_AFMT(afmt);
0070 
0071     if (afmt->ctx->dc->debug.enable_mem_low_power.bits.afmt == false)
0072         return;
0073 
0074     REG_UPDATE_2(AFMT_MEM_PWR, AFMT_MEM_PWR_DIS, 1, AFMT_MEM_PWR_FORCE, 0);
0075 }
0076 
0077 void afmt31_construct(struct dcn31_afmt *afmt31,
0078     struct dc_context *ctx,
0079     uint32_t inst,
0080     const struct dcn31_afmt_registers *afmt_regs,
0081     const struct dcn31_afmt_shift *afmt_shift,
0082     const struct dcn31_afmt_mask *afmt_mask)
0083 {
0084     afmt31->base.ctx = ctx;
0085 
0086     afmt31->base.inst = inst;
0087     afmt31->base.funcs = &dcn31_afmt_funcs;
0088 
0089     afmt31->regs = afmt_regs;
0090     afmt31->afmt_shift = afmt_shift;
0091     afmt31->afmt_mask = afmt_mask;
0092 }