@@ -516,19 +516,37 @@ void snd_pcm_set_ops(struct snd_pcm *pcm, int direction,
516
516
EXPORT_SYMBOL (snd_pcm_set_ops );
517
517
518
518
/**
519
- * snd_pcm_set_sync - set the PCM sync id
519
+ * snd_pcm_set_sync_per_card - set the PCM sync id with card number
520
520
* @substream: the pcm substream
521
+ * @params: modified hardware parameters
522
+ * @id: identifier (max 12 bytes)
523
+ * @len: identifier length (max 12 bytes)
521
524
*
522
- * Sets the PCM sync identifier for the card.
525
+ * Sets the PCM sync identifier for the card with zero padding.
526
+ *
527
+ * User space or any user should use this 16-byte identifier for a comparison only
528
+ * to check if two IDs are similar or different. Special case is the identifier
529
+ * containing only zeros. Interpretation for this combination is - empty (not set).
530
+ * The contents of the identifier should not be interpreted in any other way.
531
+ *
532
+ * The synchronization ID must be unique per clock source (usually one sound card,
533
+ * but multiple soundcard may use one PCM word clock source which means that they
534
+ * are fully synchronized).
535
+ *
536
+ * This routine composes this ID using card number in first four bytes and
537
+ * 12-byte additional ID. When other ID composition is used (e.g. for multiple
538
+ * sound cards), make sure that the composition does not clash with this
539
+ * composition scheme.
523
540
*/
524
- void snd_pcm_set_sync (struct snd_pcm_substream * substream )
541
+ void snd_pcm_set_sync_per_card (struct snd_pcm_substream * substream ,
542
+ struct snd_pcm_hw_params * params ,
543
+ const unsigned char * id , unsigned int len )
525
544
{
526
- struct snd_pcm_runtime * runtime = substream -> runtime ;
527
-
528
- * ( __u32 * ) runtime -> sync = cpu_to_le32 ( substream -> pcm -> card -> number );
529
- memset (runtime -> sync + 4 , 0xff , sizeof ( runtime -> sync ) - 4 );
545
+ * ( __u32 * ) params -> sync = cpu_to_le32 ( substream -> pcm -> card -> number ) ;
546
+ len = max ( 12 , len );
547
+ strncpy ( params -> sync + 4 , id , len );
548
+ memset (params -> sync + 4 + len , 0 , 12 - len );
530
549
}
531
- EXPORT_SYMBOL (snd_pcm_set_sync );
532
550
533
551
/*
534
552
* Standard ioctl routine
@@ -1808,22 +1826,15 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
1808
1826
return 0 ;
1809
1827
}
1810
1828
1811
- /**
1812
- * is sync id (clock id) empty?
1813
- */
1814
- static inline bool pcm_sync_empty (const unsigned char * sync )
1815
- {
1816
- return sync [0 ] == 0 && sync [1 ] == 0 && sync [2 ] == 0 && sync [3 ] == 0 &&
1817
- sync [4 ] == 0 && sync [5 ] == 0 && sync [6 ] == 0 && sync [7 ] == 0 ;
1818
- }
1819
-
1820
1829
static int snd_pcm_lib_ioctl_sync_id (struct snd_pcm_substream * substream ,
1821
1830
void * arg )
1822
1831
{
1823
- struct snd_pcm_hw_params * params = arg ;
1832
+ static const unsigned char id [12 ] = { 0xff , 0xff , 0xff , 0xff ,
1833
+ 0xff , 0xff , 0xff , 0xff ,
1834
+ 0xff , 0xff , 0xff , 0xff };
1824
1835
1825
- if (pcm_sync_empty ( params -> sync ) )
1826
- memcpy ( params -> sync , substream -> runtime -> sync , sizeof (params -> sync ));
1836
+ if (substream -> runtime -> std_sync_id )
1837
+ snd_pcm_set_sync_per_card ( substream , arg , id , sizeof (id ));
1827
1838
return 0 ;
1828
1839
}
1829
1840
0 commit comments