<html><body><p>
<pre>
Hi, Angelo:

On Wed, 2024-11-20 at 13:45 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
>
>
> Add support for the newer HDMI-TX (Encoder) v2 and DDC v2 IPs
> found in MediaTek's MT8195, MT8188 SoC and their variants, and
> including support for display modes up to 4k60 and for HDMI
> Audio, as per the HDMI 2.0 spec.
>
> HDCP and CEC functionalities are also supported by this hardware,
> but are not included in this commit.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---

[snip]

> +static int mtk_hdmi_v2_audio_hw_params(struct device *dev, void *data,
> + struct hdmi_codec_daifmt *codec_daifmt,
> + struct hdmi_codec_params *codec_params)
> +{

This function is almost the same as v1.
Try to make this function as common function.

Regards,
CK

> + struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
> + struct hdmi_audio_param aud_params = { 0 };
> +
> + if (!hdmi->bridge.encoder)
> + return -ENODEV;
> +
> + switch (codec_params->cea.channels) {
> + case 2:
> + aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0;
> + break;
> + case 4:
> + aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_4_0;
> + break;
> + case 6:
> + aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_5_1;
> + break;
> + case 8:
> + aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_7_1;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + switch (codec_params->sample_rate) {
> + case 32000:
> + case 44100:
> + case 48000:
> + case 88200:
> + case 96000:
> + case 176400:
> + case 192000:
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + switch (codec_daifmt->fmt) {
> + case HDMI_I2S:
> + aud_params.aud_codec = HDMI_AUDIO_CODING_TYPE_PCM;
> + aud_params.aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16;
> + aud_params.aud_input_type = HDMI_AUD_INPUT_I2S;
> + aud_params.aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT;
> + aud_params.aud_mclk = HDMI_AUD_MCLK_128FS;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + memcpy(&aud_params.codec_params, codec_params, sizeof(aud_params.codec_params));
> + mtk_hdmi_v2_audio_set_param(hdmi, &aud_params);
> +
> + return 0;
> +}
> +

>


</pre>
</p></body></html><!--type:text--><!--{--><pre>************* MEDIATEK Confidentiality Notice ********************
The information contained in this e-mail message (including any 
attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be 
conveyed only to the designated recipient(s). Any use, dissemination, 
distribution, printing, retaining or copying of this e-mail (including its 
attachments) by unintended recipient(s) is strictly prohibited and may 
be unlawful. If you are not an intended recipient of this e-mail, or believe 
that you have received this e-mail in error, please notify the sender 
immediately (by replying to this e-mail), delete any and all copies of 
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!
</pre><!--}-->