@@ -261,22 +261,18 @@ static int mca_fe_trigger(struct snd_pcm_substream *substream, int cmd,
261261 return 0 ;
262262}
263263
264- static int mca_fe_get_port (struct snd_pcm_substream * substream )
264+ static int mca_fe_get_portmask (struct snd_pcm_substream * substream )
265265{
266266 struct snd_soc_pcm_runtime * fe = snd_soc_substream_to_rtd (substream );
267- struct snd_soc_pcm_runtime * be ;
268267 struct snd_soc_dpcm * dpcm ;
268+ int mask = 0 ;
269269
270- be = NULL ;
271270 for_each_dpcm_be (fe , substream -> stream , dpcm ) {
272- be = dpcm -> be ;
273- break ;
271+ int no = mca_dai_to_cluster ( snd_soc_rtd_to_cpu ( dpcm -> be , 0 )) -> no ;
272+ mask |= 1 << no ;
274273 }
275274
276- if (!be )
277- return - EINVAL ;
278-
279- return mca_dai_to_cluster (snd_soc_rtd_to_cpu (be , 0 ))-> no ;
275+ return mask ;
280276}
281277
282278static int mca_fe_enable_clocks (struct mca_cluster * cl )
@@ -391,7 +387,7 @@ static int mca_fe_prepare(struct snd_pcm_substream *substream,
391387 return 0 ;
392388
393389 if (!cl -> syncgen_in_use ) {
394- int port = mca_fe_get_port ( substream );
390+ int port = ffs ( mca_fe_get_portmask ( substream )) - 1 ;
395391
396392 cl -> pd_link = device_link_add (mca -> dev , cl -> pd_dev ,
397393 DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
@@ -441,7 +437,7 @@ static unsigned int mca_crop_mask(unsigned int mask, int nchans)
441437
442438static int mca_configure_serdes (struct mca_cluster * cl , int serdes_unit ,
443439 unsigned int mask , int slots , int nchans ,
444- int slot_width , bool is_tx , int port )
440+ int slot_width , bool is_tx , int portmask )
445441{
446442 __iomem void * serdes_base = cl -> base + serdes_unit ;
447443 u32 serdes_conf , serdes_conf_mask ;
@@ -500,7 +496,7 @@ static int mca_configure_serdes(struct mca_cluster *cl, int serdes_unit,
500496 serdes_base + REG_RX_SERDES_SLOTMASK );
501497 writel_relaxed (~((u32 )mca_crop_mask (mask , nchans )),
502498 serdes_base + REG_RX_SERDES_SLOTMASK + 0x4 );
503- writel_relaxed (1 << port ,
499+ writel_relaxed (portmask ,
504500 serdes_base + REG_RX_SERDES_PORT );
505501 }
506502
@@ -637,7 +633,7 @@ static int mca_fe_hw_params(struct snd_pcm_substream *substream,
637633 unsigned long bclk_ratio ;
638634 unsigned int tdm_slots , tdm_slot_width , tdm_mask ;
639635 u32 regval , pad ;
640- int ret , port , nchans_ceiled ;
636+ int ret , portmask , nchans_ceiled ;
641637
642638 if (!cl -> tdm_slot_width ) {
643639 /*
@@ -686,13 +682,13 @@ static int mca_fe_hw_params(struct snd_pcm_substream *substream,
686682 tdm_mask = (1 << tdm_slots ) - 1 ;
687683 }
688684
689- port = mca_fe_get_port (substream );
690- if (port < 0 )
691- return port ;
685+ portmask = mca_fe_get_portmask (substream );
686+ if (! portmask )
687+ return - EINVAL ;
692688
693689 ret = mca_configure_serdes (cl , is_tx ? CLUSTER_TX_OFF : CLUSTER_RX_OFF ,
694690 tdm_mask , tdm_slots , params_channels (params ),
695- tdm_slot_width , is_tx , port );
691+ tdm_slot_width , is_tx , portmask );
696692 if (ret )
697693 return ret ;
698694
0 commit comments