Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2020 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 #ifndef __DAL_DCN30_AFMT_H__
0027 #define __DAL_DCN30_AFMT_H__
0028 
0029 
0030 #define DCN30_AFMT_FROM_AFMT(afmt)\
0031     container_of(afmt, struct dcn30_afmt, base)
0032 
0033 #define AFMT_DCN3_REG_LIST(id) \
0034     SRI(AFMT_INFOFRAME_CONTROL0, AFMT, id), \
0035     SRI(AFMT_VBI_PACKET_CONTROL, AFMT, id), \
0036     SRI(AFMT_AUDIO_PACKET_CONTROL, AFMT, id), \
0037     SRI(AFMT_AUDIO_PACKET_CONTROL2, AFMT, id), \
0038     SRI(AFMT_AUDIO_SRC_CONTROL, AFMT, id), \
0039     SRI(AFMT_60958_0, AFMT, id), \
0040     SRI(AFMT_60958_1, AFMT, id), \
0041     SRI(AFMT_60958_2, AFMT, id), \
0042     SRI(AFMT_MEM_PWR, AFMT, id)
0043 
0044 struct dcn30_afmt_registers {
0045     uint32_t AFMT_INFOFRAME_CONTROL0;
0046     uint32_t AFMT_VBI_PACKET_CONTROL;
0047     uint32_t AFMT_AUDIO_PACKET_CONTROL;
0048     uint32_t AFMT_AUDIO_PACKET_CONTROL2;
0049     uint32_t AFMT_AUDIO_SRC_CONTROL;
0050     uint32_t AFMT_60958_0;
0051     uint32_t AFMT_60958_1;
0052     uint32_t AFMT_60958_2;
0053     uint32_t AFMT_MEM_PWR;
0054 };
0055 
0056 #define DCN3_AFMT_MASK_SH_LIST(mask_sh)\
0057     SE_SF(AFMT0_AFMT_INFOFRAME_CONTROL0, AFMT_AUDIO_INFO_UPDATE, mask_sh),\
0058     SE_SF(AFMT0_AFMT_AUDIO_SRC_CONTROL, AFMT_AUDIO_SRC_SELECT, mask_sh),\
0059     SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL2, AFMT_AUDIO_CHANNEL_ENABLE, mask_sh),\
0060     SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL, AFMT_60958_CS_UPDATE, mask_sh),\
0061     SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL2, AFMT_AUDIO_LAYOUT_OVRD, mask_sh),\
0062     SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL2, AFMT_60958_OSF_OVRD, mask_sh),\
0063     SE_SF(AFMT0_AFMT_60958_0, AFMT_60958_CS_CHANNEL_NUMBER_L, mask_sh),\
0064     SE_SF(AFMT0_AFMT_60958_0, AFMT_60958_CS_CLOCK_ACCURACY, mask_sh),\
0065     SE_SF(AFMT0_AFMT_60958_1, AFMT_60958_CS_CHANNEL_NUMBER_R, mask_sh),\
0066     SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_2, mask_sh),\
0067     SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_3, mask_sh),\
0068     SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_4, mask_sh),\
0069     SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_5, mask_sh),\
0070     SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_6, mask_sh),\
0071     SE_SF(AFMT0_AFMT_60958_2, AFMT_60958_CS_CHANNEL_NUMBER_7, mask_sh),\
0072     SE_SF(AFMT0_AFMT_AUDIO_PACKET_CONTROL, AFMT_AUDIO_SAMPLE_SEND, mask_sh),\
0073     SE_SF(AFMT0_AFMT_MEM_PWR, AFMT_MEM_PWR_FORCE, mask_sh)
0074 
0075 #define AFMT_DCN3_REG_FIELD_LIST(type) \
0076         type AFMT_AUDIO_INFO_UPDATE;\
0077         type AFMT_AUDIO_SRC_SELECT;\
0078         type AFMT_AUDIO_CHANNEL_ENABLE;\
0079         type AFMT_60958_CS_UPDATE;\
0080         type AFMT_AUDIO_LAYOUT_OVRD;\
0081         type AFMT_60958_OSF_OVRD;\
0082         type AFMT_60958_CS_CHANNEL_NUMBER_L;\
0083         type AFMT_60958_CS_CLOCK_ACCURACY;\
0084         type AFMT_60958_CS_CHANNEL_NUMBER_R;\
0085         type AFMT_60958_CS_CHANNEL_NUMBER_2;\
0086         type AFMT_60958_CS_CHANNEL_NUMBER_3;\
0087         type AFMT_60958_CS_CHANNEL_NUMBER_4;\
0088         type AFMT_60958_CS_CHANNEL_NUMBER_5;\
0089         type AFMT_60958_CS_CHANNEL_NUMBER_6;\
0090         type AFMT_60958_CS_CHANNEL_NUMBER_7;\
0091         type AFMT_AUDIO_SAMPLE_SEND;\
0092         type AFMT_MEM_PWR_FORCE
0093 
0094 struct dcn30_afmt_shift {
0095     AFMT_DCN3_REG_FIELD_LIST(uint8_t);
0096 };
0097 
0098 struct dcn30_afmt_mask {
0099     AFMT_DCN3_REG_FIELD_LIST(uint32_t);
0100 };
0101 
0102 
0103 struct afmt;
0104 
0105 struct afmt_funcs {
0106 
0107     void (*setup_hdmi_audio)(
0108         struct afmt *afmt);
0109 
0110     void (*se_audio_setup)(
0111         struct afmt *afmt,
0112         unsigned int az_inst,
0113         struct audio_info *audio_info);
0114 
0115     void (*audio_mute_control)(
0116         struct afmt *afmt,
0117         bool mute);
0118 
0119     void (*audio_info_immediate_update)(
0120         struct afmt *afmt);
0121 
0122     void (*setup_dp_audio)(
0123         struct afmt *afmt);
0124 
0125     void (*afmt_poweron)(
0126         struct afmt *afmt);
0127 
0128     void (*afmt_powerdown)(
0129         struct afmt *afmt);
0130 };
0131 
0132 struct afmt {
0133     const struct afmt_funcs *funcs;
0134     struct dc_context *ctx;
0135     int inst;
0136 };
0137 
0138 struct dcn30_afmt {
0139     struct afmt base;
0140     const struct dcn30_afmt_registers *regs;
0141     const struct dcn30_afmt_shift *afmt_shift;
0142     const struct dcn30_afmt_mask *afmt_mask;
0143 };
0144 
0145 void afmt3_setup_hdmi_audio(
0146     struct afmt *afmt);
0147 
0148 void afmt3_se_audio_setup(
0149     struct afmt *afmt,
0150     unsigned int az_inst,
0151     struct audio_info *audio_info);
0152 
0153 void afmt3_audio_mute_control(
0154     struct afmt *afmt,
0155     bool mute);
0156 
0157 void afmt3_audio_info_immediate_update(
0158     struct afmt *afmt);
0159 
0160 void afmt3_setup_dp_audio(
0161         struct afmt *afmt);
0162 
0163 void afmt3_construct(struct dcn30_afmt *afmt3,
0164     struct dc_context *ctx,
0165     uint32_t inst,
0166     const struct dcn30_afmt_registers *afmt_regs,
0167     const struct dcn30_afmt_shift *afmt_shift,
0168     const struct dcn30_afmt_mask *afmt_mask);
0169 
0170 
0171 #endif