@@ -191,8 +191,6 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
191191 struct snd_pcm_runtime * runtime )
192192{
193193 struct snd_pcm_hardware * hw = & runtime -> hw ;
194- unsigned int ctx_header_size ;
195- unsigned int maximum_usec_per_period ;
196194 int err ;
197195
198196 hw -> info = SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -212,21 +210,6 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
212210 hw -> period_bytes_max = hw -> period_bytes_min * 2048 ;
213211 hw -> buffer_bytes_max = hw -> period_bytes_max * hw -> periods_min ;
214212
215- // Linux driver for 1394 OHCI controller voluntarily flushes isoc
216- // context when total size of accumulated context header reaches
217- // PAGE_SIZE. This kicks work for the isoc context and brings
218- // callback in the middle of scheduled interrupts.
219- // Although AMDTP streams in the same domain use the same events per
220- // IRQ, use the largest size of context header between IT/IR contexts.
221- // Here, use the value of context header in IR context is for both
222- // contexts.
223- if (!(s -> flags & CIP_NO_HEADER ))
224- ctx_header_size = IR_CTX_HEADER_SIZE_CIP ;
225- else
226- ctx_header_size = IR_CTX_HEADER_SIZE_NO_CIP ;
227- maximum_usec_per_period = USEC_PER_SEC * PAGE_SIZE /
228- CYCLES_PER_SECOND / ctx_header_size ;
229-
230213 // In IEC 61883-6, one isoc packet can transfer events up to the value
231214 // of syt interval. This comes from the interval of isoc cycle. As 1394
232215 // OHCI controller can generate hardware IRQ per isoc packet, the
@@ -239,9 +222,10 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
239222 // Due to the above protocol design, the minimum PCM frames per
240223 // interrupt should be double of the value of syt interval, thus it is
241224 // 250 usec.
225+ // There is no reason, but up to 250 msec to avoid consuming resources so much.
242226 err = snd_pcm_hw_constraint_minmax (runtime ,
243227 SNDRV_PCM_HW_PARAM_PERIOD_TIME ,
244- 250 , maximum_usec_per_period );
228+ 250 , USEC_PER_SEC / 4 );
245229 if (err < 0 )
246230 goto end ;
247231
@@ -261,6 +245,7 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
261245 SNDRV_PCM_HW_PARAM_RATE , -1 );
262246 if (err < 0 )
263247 goto end ;
248+
264249 err = snd_pcm_hw_rule_add (runtime , 0 , SNDRV_PCM_HW_PARAM_BUFFER_SIZE ,
265250 apply_constraint_to_size , NULL ,
266251 SNDRV_PCM_HW_PARAM_BUFFER_SIZE ,
@@ -1715,7 +1700,9 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
17151700 } else {
17161701 dir = DMA_TO_DEVICE ;
17171702 type = FW_ISO_CONTEXT_TRANSMIT ;
1718- ctx_header_size = 0 ; // No effect for IT context.
1703+ // Although no effect for IT context, this value is required to compute the size
1704+ // of header storage correctly.
1705+ ctx_header_size = sizeof (__be32 );
17191706 }
17201707 max_ctx_payload_size = amdtp_stream_get_max_ctx_payload_size (s );
17211708
@@ -1724,9 +1711,9 @@ static int amdtp_stream_start(struct amdtp_stream *s, int channel, int speed,
17241711 return err ;
17251712 s -> queue_size = queue_size ;
17261713
1727- s -> context = fw_iso_context_create ( fw_parent_device ( s -> unit ) -> card ,
1728- type , channel , speed , ctx_header_size ,
1729- amdtp_stream_first_callback , s );
1714+ s -> context = fw_iso_context_create_with_header_storage_size (
1715+ fw_parent_device ( s -> unit ) -> card , type , channel , speed , ctx_header_size ,
1716+ ctx_header_size * queue_size , amdtp_stream_first_callback , s );
17301717 if (IS_ERR (s -> context )) {
17311718 err = PTR_ERR (s -> context );
17321719 if (err == - EBUSY )
0 commit comments