1717#include <sound/pcm_params.h>
1818#include <sound/soc.h>
1919
20- struct qmc_dai_chan {
21- struct qmc_dai_prtd * prtd_tx ;
22- struct qmc_dai_prtd * prtd_rx ;
23- struct qmc_chan * qmc_chan ;
24- };
25-
2620struct qmc_dai {
2721 char * name ;
2822 int id ;
@@ -33,7 +27,7 @@ struct qmc_dai {
3327 unsigned int nb_chans_avail ;
3428 unsigned int nb_chans_used_tx ;
3529 unsigned int nb_chans_used_rx ;
36- struct qmc_dai_chan * chans ;
30+ struct qmc_chan * * qmc_chans ;
3731};
3832
3933struct qmc_audio {
@@ -125,7 +119,7 @@ static int qmc_audio_pcm_write_submit(struct qmc_dai_prtd *prtd)
125119 int ret ;
126120
127121 for (i = 0 ; i < prtd -> channels ; i ++ ) {
128- ret = qmc_chan_write_submit (prtd -> qmc_dai -> chans [i ]. qmc_chan ,
122+ ret = qmc_chan_write_submit (prtd -> qmc_dai -> qmc_chans [i ],
129123 prtd -> ch_dma_addr_current + i * prtd -> ch_dma_offset ,
130124 prtd -> ch_dma_size ,
131125 i == prtd -> channels - 1 ? qmc_audio_pcm_write_complete :
@@ -165,7 +159,7 @@ static int qmc_audio_pcm_read_submit(struct qmc_dai_prtd *prtd)
165159 int ret ;
166160
167161 for (i = 0 ; i < prtd -> channels ; i ++ ) {
168- ret = qmc_chan_read_submit (prtd -> qmc_dai -> chans [i ]. qmc_chan ,
162+ ret = qmc_chan_read_submit (prtd -> qmc_dai -> qmc_chans [i ],
169163 prtd -> ch_dma_addr_current + i * prtd -> ch_dma_offset ,
170164 prtd -> ch_dma_size ,
171165 i == prtd -> channels - 1 ? qmc_audio_pcm_read_complete :
@@ -206,7 +200,6 @@ static int qmc_audio_pcm_trigger(struct snd_soc_component *component,
206200 struct snd_pcm_substream * substream , int cmd )
207201{
208202 struct qmc_dai_prtd * prtd = substream -> runtime -> private_data ;
209- unsigned int i ;
210203 int ret ;
211204
212205 if (!prtd -> qmc_dai ) {
@@ -220,9 +213,6 @@ static int qmc_audio_pcm_trigger(struct snd_soc_component *component,
220213 prtd -> ch_dma_addr_current = prtd -> ch_dma_addr_start ;
221214
222215 if (substream -> stream == SNDRV_PCM_STREAM_PLAYBACK ) {
223- for (i = 0 ; i < prtd -> channels ; i ++ )
224- prtd -> qmc_dai -> chans [i ].prtd_tx = prtd ;
225-
226216 /* Submit first chunk ... */
227217 ret = qmc_audio_pcm_write_submit (prtd );
228218 if (ret )
@@ -238,9 +228,6 @@ static int qmc_audio_pcm_trigger(struct snd_soc_component *component,
238228 if (ret )
239229 return ret ;
240230 } else {
241- for (i = 0 ; i < prtd -> channels ; i ++ )
242- prtd -> qmc_dai -> chans [i ].prtd_rx = prtd ;
243-
244231 /* Submit first chunk ... */
245232 ret = qmc_audio_pcm_read_submit (prtd );
246233 if (ret )
@@ -610,9 +597,9 @@ static int qmc_dai_hw_params(struct snd_pcm_substream *substream,
610597 chan_param .mode = QMC_TRANSPARENT ;
611598 chan_param .transp .max_rx_buf_size = params_period_bytes (params ) / nb_chans_used ;
612599 for (i = 0 ; i < nb_chans_used ; i ++ ) {
613- ret = qmc_chan_set_param (qmc_dai -> chans [i ]. qmc_chan , & chan_param );
600+ ret = qmc_chan_set_param (qmc_dai -> qmc_chans [i ], & chan_param );
614601 if (ret ) {
615- dev_err (dai -> dev , "chans [%u], set param failed %d\n" ,
602+ dev_err (dai -> dev , "qmc_chans [%u], set param failed %d\n" ,
616603 i , ret );
617604 return ret ;
618605 }
@@ -654,7 +641,7 @@ static int qmc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
654641 case SNDRV_PCM_TRIGGER_RESUME :
655642 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE :
656643 for (i = 0 ; i < nb_chans_used ; i ++ ) {
657- ret = qmc_chan_start (qmc_dai -> chans [i ]. qmc_chan , direction );
644+ ret = qmc_chan_start (qmc_dai -> qmc_chans [i ], direction );
658645 if (ret )
659646 goto err_stop ;
660647 }
@@ -663,13 +650,13 @@ static int qmc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
663650 case SNDRV_PCM_TRIGGER_STOP :
664651 /* Stop and reset all QMC channels and return the first error encountered */
665652 for (i = 0 ; i < nb_chans_used ; i ++ ) {
666- ret_tmp = qmc_chan_stop (qmc_dai -> chans [i ]. qmc_chan , direction );
653+ ret_tmp = qmc_chan_stop (qmc_dai -> qmc_chans [i ], direction );
667654 if (!ret )
668655 ret = ret_tmp ;
669656 if (ret_tmp )
670657 continue ;
671658
672- ret_tmp = qmc_chan_reset (qmc_dai -> chans [i ]. qmc_chan , direction );
659+ ret_tmp = qmc_chan_reset (qmc_dai -> qmc_chans [i ], direction );
673660 if (!ret )
674661 ret = ret_tmp ;
675662 }
@@ -681,7 +668,7 @@ static int qmc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
681668 case SNDRV_PCM_TRIGGER_PAUSE_PUSH :
682669 /* Stop all QMC channels and return the first error encountered */
683670 for (i = 0 ; i < nb_chans_used ; i ++ ) {
684- ret_tmp = qmc_chan_stop (qmc_dai -> chans [i ]. qmc_chan , direction );
671+ ret_tmp = qmc_chan_stop (qmc_dai -> qmc_chans [i ], direction );
685672 if (!ret )
686673 ret = ret_tmp ;
687674 }
@@ -697,8 +684,8 @@ static int qmc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
697684
698685err_stop :
699686 while (i -- ) {
700- qmc_chan_stop (qmc_dai -> chans [i ]. qmc_chan , direction );
701- qmc_chan_reset (qmc_dai -> chans [i ]. qmc_chan , direction );
687+ qmc_chan_stop (qmc_dai -> qmc_chans [i ], direction );
688+ qmc_chan_reset (qmc_dai -> qmc_chans [i ], direction );
702689 }
703690 return ret ;
704691}
@@ -794,19 +781,20 @@ static int qmc_audio_dai_parse(struct qmc_audio *qmc_audio, struct device_node *
794781 return dev_err_probe (qmc_audio -> dev , - EINVAL ,
795782 "dai %d no QMC channel defined\n" , qmc_dai -> id );
796783
797- qmc_dai -> chans = devm_kcalloc (qmc_audio -> dev , count , sizeof (* qmc_dai -> chans ), GFP_KERNEL );
798- if (!qmc_dai -> chans )
784+ qmc_dai -> qmc_chans = devm_kcalloc (qmc_audio -> dev , count , sizeof (* qmc_dai -> qmc_chans ),
785+ GFP_KERNEL );
786+ if (!qmc_dai -> qmc_chans )
799787 return - ENOMEM ;
800788
801789 for (i = 0 ; i < count ; i ++ ) {
802- qmc_dai -> chans [i ]. qmc_chan = devm_qmc_chan_get_byphandles_index (qmc_audio -> dev , np ,
803- "fsl,qmc-chan" , i );
804- if (IS_ERR (qmc_dai -> chans [i ]. qmc_chan )) {
805- return dev_err_probe (qmc_audio -> dev , PTR_ERR (qmc_dai -> chans [i ]. qmc_chan ),
790+ qmc_dai -> qmc_chans [i ] = devm_qmc_chan_get_byphandles_index (qmc_audio -> dev , np ,
791+ "fsl,qmc-chan" , i );
792+ if (IS_ERR (qmc_dai -> qmc_chans [i ])) {
793+ return dev_err_probe (qmc_audio -> dev , PTR_ERR (qmc_dai -> qmc_chans [i ]),
806794 "dai %d get QMC channel %d failed\n" , qmc_dai -> id , i );
807795 }
808796
809- ret = qmc_chan_get_info (qmc_dai -> chans [i ]. qmc_chan , & info );
797+ ret = qmc_chan_get_info (qmc_dai -> qmc_chans [i ], & info );
810798 if (ret ) {
811799 dev_err (qmc_audio -> dev , "dai %d get QMC %d channel info failed %d\n" ,
812800 qmc_dai -> id , i , ret );
@@ -851,7 +839,7 @@ static int qmc_audio_dai_parse(struct qmc_audio *qmc_audio, struct device_node *
851839 }
852840 }
853841
854- ret = qmc_chan_get_ts_info (qmc_dai -> chans [i ]. qmc_chan , & ts_info );
842+ ret = qmc_chan_get_ts_info (qmc_dai -> qmc_chans [i ], & ts_info );
855843 if (ret ) {
856844 dev_err (qmc_audio -> dev , "dai %d get QMC %d channel TS info failed %d\n" ,
857845 qmc_dai -> id , i , ret );
0 commit comments