amdtp-stream.c (1dba9db0eaa64d362d9d9afb5eeaececdaef948d) | amdtp-stream.c (a9c4284bf5a95c4788e7fbf3c46b14dcbfda3a6d) |
---|---|
1/* 2 * Audio and Music Data Transmission Protocol (IEC 61883-6) streams 3 * with Common Isochronous Packet (IEC 61883-1) headers 4 * 5 * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 6 * Licensed under the terms of the GNU General Public License, version 2. 7 */ 8 --- 395 unchanged lines hidden (view full) --- 404} 405 406static inline int queue_in_packet(struct amdtp_stream *s) 407{ 408 return queue_packet(s, IN_PACKET_HEADER_SIZE, 409 amdtp_stream_get_max_payload(s), false); 410} 411 | 1/* 2 * Audio and Music Data Transmission Protocol (IEC 61883-6) streams 3 * with Common Isochronous Packet (IEC 61883-1) headers 4 * 5 * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 6 * Licensed under the terms of the GNU General Public License, version 2. 7 */ 8 --- 395 unchanged lines hidden (view full) --- 404} 405 406static inline int queue_in_packet(struct amdtp_stream *s) 407{ 408 return queue_packet(s, IN_PACKET_HEADER_SIZE, 409 amdtp_stream_get_max_payload(s), false); 410} 411 |
412static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle) | 412static int handle_out_packet(struct amdtp_stream *s, unsigned int cycle, 413 unsigned int index) |
413{ 414 __be32 *buffer; 415 unsigned int syt; 416 unsigned int data_blocks; 417 unsigned int payload_length; 418 unsigned int pcm_frames; 419 struct snd_pcm_substream *pcm; 420 --- 8 unchanged lines hidden (view full) --- 429 buffer[1] = cpu_to_be32(CIP_EOH | 430 ((s->fmt << CIP_FMT_SHIFT) & CIP_FMT_MASK) | 431 ((s->fdf << CIP_FDF_SHIFT) & CIP_FDF_MASK) | 432 (syt & CIP_SYT_MASK)); 433 434 s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; 435 payload_length = 8 + data_blocks * 4 * s->data_block_quadlets; 436 | 414{ 415 __be32 *buffer; 416 unsigned int syt; 417 unsigned int data_blocks; 418 unsigned int payload_length; 419 unsigned int pcm_frames; 420 struct snd_pcm_substream *pcm; 421 --- 8 unchanged lines hidden (view full) --- 430 buffer[1] = cpu_to_be32(CIP_EOH | 431 ((s->fmt << CIP_FMT_SHIFT) & CIP_FMT_MASK) | 432 ((s->fdf << CIP_FDF_SHIFT) & CIP_FDF_MASK) | 433 (syt & CIP_SYT_MASK)); 434 435 s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff; 436 payload_length = 8 + data_blocks * 4 * s->data_block_quadlets; 437 |
437 trace_out_packet(s, cycle, buffer, payload_length); | 438 trace_out_packet(s, cycle, buffer, payload_length, index); |
438 439 if (queue_out_packet(s, payload_length, false) < 0) 440 return -EIO; 441 442 pcm = ACCESS_ONCE(s->pcm); 443 if (pcm && pcm_frames > 0) 444 update_pcm_pointers(s, pcm, pcm_frames); 445 446 /* No need to return the number of handled data blocks. */ 447 return 0; 448} 449 450static int handle_in_packet(struct amdtp_stream *s, | 439 440 if (queue_out_packet(s, payload_length, false) < 0) 441 return -EIO; 442 443 pcm = ACCESS_ONCE(s->pcm); 444 if (pcm && pcm_frames > 0) 445 update_pcm_pointers(s, pcm, pcm_frames); 446 447 /* No need to return the number of handled data blocks. */ 448 return 0; 449} 450 451static int handle_in_packet(struct amdtp_stream *s, |
451 unsigned int payload_quadlets, unsigned int cycle) | 452 unsigned int payload_quadlets, unsigned int cycle, 453 unsigned int index) |
452{ 453 __be32 *buffer; 454 u32 cip_header[2]; 455 unsigned int fmt, fdf, syt; 456 unsigned int data_block_quadlets, data_block_counter, dbc_interval; 457 unsigned int data_blocks; 458 struct snd_pcm_substream *pcm; 459 unsigned int pcm_frames; 460 bool lost; 461 462 buffer = s->buffer.packets[s->packet_index].buffer; 463 cip_header[0] = be32_to_cpu(buffer[0]); 464 cip_header[1] = be32_to_cpu(buffer[1]); 465 | 454{ 455 __be32 *buffer; 456 u32 cip_header[2]; 457 unsigned int fmt, fdf, syt; 458 unsigned int data_block_quadlets, data_block_counter, dbc_interval; 459 unsigned int data_blocks; 460 struct snd_pcm_substream *pcm; 461 unsigned int pcm_frames; 462 bool lost; 463 464 buffer = s->buffer.packets[s->packet_index].buffer; 465 cip_header[0] = be32_to_cpu(buffer[0]); 466 cip_header[1] = be32_to_cpu(buffer[1]); 467 |
466 trace_in_packet(s, cycle, cip_header, payload_quadlets); | 468 trace_in_packet(s, cycle, cip_header, payload_quadlets, index); |
467 468 /* 469 * This module supports 'Two-quadlet CIP header with SYT field'. 470 * For convenience, also check FMT field is AM824 or not. 471 */ 472 if (((cip_header[0] & CIP_EOH_MASK) == CIP_EOH) || 473 ((cip_header[1] & CIP_EOH_MASK) != CIP_EOH)) { 474 dev_info_ratelimited(&s->unit->device, --- 122 unchanged lines hidden (view full) --- 597 598 cycle = compute_cycle_count(tstamp); 599 600 /* Align to actual cycle count for the last packet. */ 601 cycle = increment_cycle_count(cycle, QUEUE_LENGTH - packets); 602 603 for (i = 0; i < packets; ++i) { 604 cycle = increment_cycle_count(cycle, 1); | 469 470 /* 471 * This module supports 'Two-quadlet CIP header with SYT field'. 472 * For convenience, also check FMT field is AM824 or not. 473 */ 474 if (((cip_header[0] & CIP_EOH_MASK) == CIP_EOH) || 475 ((cip_header[1] & CIP_EOH_MASK) != CIP_EOH)) { 476 dev_info_ratelimited(&s->unit->device, --- 122 unchanged lines hidden (view full) --- 599 600 cycle = compute_cycle_count(tstamp); 601 602 /* Align to actual cycle count for the last packet. */ 603 cycle = increment_cycle_count(cycle, QUEUE_LENGTH - packets); 604 605 for (i = 0; i < packets; ++i) { 606 cycle = increment_cycle_count(cycle, 1); |
605 if (handle_out_packet(s, cycle) < 0) { | 607 if (handle_out_packet(s, cycle, i) < 0) { |
606 s->packet_index = -1; 607 amdtp_stream_pcm_abort(s); 608 return; 609 } 610 } 611 612 fw_iso_context_queue_flush(s->context); 613} --- 30 unchanged lines hidden (view full) --- 644 (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT) / 4; 645 if (payload_quadlets > max_payload_quadlets) { 646 dev_err(&s->unit->device, 647 "Detect jumbo payload: %02x %02x\n", 648 payload_quadlets, max_payload_quadlets); 649 break; 650 } 651 | 608 s->packet_index = -1; 609 amdtp_stream_pcm_abort(s); 610 return; 611 } 612 } 613 614 fw_iso_context_queue_flush(s->context); 615} --- 30 unchanged lines hidden (view full) --- 646 (be32_to_cpu(headers[i]) >> ISO_DATA_LENGTH_SHIFT) / 4; 647 if (payload_quadlets > max_payload_quadlets) { 648 dev_err(&s->unit->device, 649 "Detect jumbo payload: %02x %02x\n", 650 payload_quadlets, max_payload_quadlets); 651 break; 652 } 653 |
652 if (handle_in_packet(s, payload_quadlets, cycle) < 0) | 654 if (handle_in_packet(s, payload_quadlets, cycle, i) < 0) |
653 break; 654 } 655 656 /* Queueing error or detecting invalid payload. */ 657 if (i < packets) { 658 s->packet_index = -1; 659 amdtp_stream_pcm_abort(s); 660 return; --- 223 unchanged lines hidden --- | 655 break; 656 } 657 658 /* Queueing error or detecting invalid payload. */ 659 if (i < packets) { 660 s->packet_index = -1; 661 amdtp_stream_pcm_abort(s); 662 return; --- 223 unchanged lines hidden --- |