@@ -1450,19 +1450,13 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
14501450 * HDMI audio codec callbacks
14511451 */
14521452
1453- static int mtk_hdmi_audio_hw_params (struct device * dev , void * data ,
1454- struct hdmi_codec_daifmt * daifmt ,
1455- struct hdmi_codec_params * params )
1453+ static int mtk_hdmi_audio_params (struct mtk_hdmi * hdmi ,
1454+ struct hdmi_codec_daifmt * daifmt ,
1455+ struct hdmi_codec_params * params )
14561456{
1457- struct mtk_hdmi * hdmi = dev_get_drvdata (dev );
1458- struct hdmi_audio_param hdmi_params ;
1457+ struct hdmi_audio_param aud_params = { 0 };
14591458 unsigned int chan = params -> cea .channels ;
14601459
1461- if (!hdmi -> audio_enable ) {
1462- dev_err (hdmi -> dev , "hdmi audio is in disable state!\n" );
1463- return - EINVAL ;
1464- }
1465-
14661460 dev_dbg (hdmi -> dev , "%s: %u Hz, %d bit, %d channels\n" , __func__ ,
14671461 params -> sample_rate , params -> sample_width , chan );
14681462
@@ -1471,16 +1465,16 @@ static int mtk_hdmi_audio_hw_params(struct device *dev, void *data,
14711465
14721466 switch (chan ) {
14731467 case 2 :
1474- hdmi_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0 ;
1468+ aud_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0 ;
14751469 break ;
14761470 case 4 :
1477- hdmi_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_4_0 ;
1471+ aud_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_4_0 ;
14781472 break ;
14791473 case 6 :
1480- hdmi_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_5_1 ;
1474+ aud_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_5_1 ;
14811475 break ;
14821476 case 8 :
1483- hdmi_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_7_1 ;
1477+ aud_params .aud_input_chan_type = HDMI_AUD_CHAN_TYPE_7_1 ;
14841478 break ;
14851479 default :
14861480 dev_err (hdmi -> dev , "channel[%d] not supported!\n" , chan );
@@ -1504,31 +1498,44 @@ static int mtk_hdmi_audio_hw_params(struct device *dev, void *data,
15041498
15051499 switch (daifmt -> fmt ) {
15061500 case HDMI_I2S :
1507- hdmi_params .aud_codec = HDMI_AUDIO_CODING_TYPE_PCM ;
1508- hdmi_params .aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16 ;
1509- hdmi_params .aud_input_type = HDMI_AUD_INPUT_I2S ;
1510- hdmi_params .aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT ;
1511- hdmi_params .aud_mclk = HDMI_AUD_MCLK_128FS ;
1501+ aud_params .aud_codec = HDMI_AUDIO_CODING_TYPE_PCM ;
1502+ aud_params .aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16 ;
1503+ aud_params .aud_input_type = HDMI_AUD_INPUT_I2S ;
1504+ aud_params .aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT ;
1505+ aud_params .aud_mclk = HDMI_AUD_MCLK_128FS ;
15121506 break ;
15131507 case HDMI_SPDIF :
1514- hdmi_params .aud_codec = HDMI_AUDIO_CODING_TYPE_PCM ;
1515- hdmi_params .aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16 ;
1516- hdmi_params .aud_input_type = HDMI_AUD_INPUT_SPDIF ;
1508+ aud_params .aud_codec = HDMI_AUDIO_CODING_TYPE_PCM ;
1509+ aud_params .aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16 ;
1510+ aud_params .aud_input_type = HDMI_AUD_INPUT_SPDIF ;
15171511 break ;
15181512 default :
15191513 dev_err (hdmi -> dev , "%s: Invalid DAI format %d\n" , __func__ ,
15201514 daifmt -> fmt );
15211515 return - EINVAL ;
15221516 }
1523-
1524- memcpy (& hdmi_params .codec_params , params ,
1525- sizeof (hdmi_params .codec_params ));
1526- memcpy (& hdmi -> aud_param , & hdmi_params , sizeof (hdmi_params ));
1517+ memcpy (& aud_params .codec_params , params , sizeof (aud_params .codec_params ));
1518+ memcpy (& hdmi -> aud_param , & aud_params , sizeof (aud_params ));
15271519
15281520 dev_dbg (hdmi -> dev , "codec:%d, input:%d, channel:%d, fs:%d\n" ,
1529- hdmi_params .aud_codec , hdmi_params .aud_input_type ,
1530- hdmi_params .aud_input_chan_type , hdmi_params .codec_params .sample_rate );
1521+ aud_params .aud_codec , aud_params .aud_input_type ,
1522+ aud_params .aud_input_chan_type , aud_params .codec_params .sample_rate );
1523+
1524+ return 0 ;
1525+ }
1526+
1527+ static int mtk_hdmi_audio_hw_params (struct device * dev , void * data ,
1528+ struct hdmi_codec_daifmt * daifmt ,
1529+ struct hdmi_codec_params * params )
1530+ {
1531+ struct mtk_hdmi * hdmi = dev_get_drvdata (dev );
1532+
1533+ if (!hdmi -> audio_enable ) {
1534+ dev_err (hdmi -> dev , "hdmi audio is in disable state!\n" );
1535+ return - EINVAL ;
1536+ }
15311537
1538+ mtk_hdmi_audio_params (hdmi , daifmt , params );
15321539 mtk_hdmi_aud_output_config (hdmi , & hdmi -> mode );
15331540
15341541 return 0 ;
0 commit comments