1 // SPDX-License-Identifier: GPL-2.0-only 1 2 // 3 // motu-command-dsp-message-parser.c - a part 4 // 5 // Copyright (c) 2021 Takashi Sakamoto <o-taka 6 7 // Below models allow software to configure th 8 // asynchronous transaction: 9 // * 828 mk3 (FireWire only and Hybrid) 10 // * 896 mk3 (FireWire only and Hybrid) 11 // * Ultralite mk3 (FireWire only and Hybrid) 12 // * Traveler mk3 13 // * Track 16 14 // 15 // Isochronous packets from the above models i 16 17 #include "motu.h" 18 19 enum msg_parser_state { 20 INITIALIZED, 21 FRAGMENT_DETECTED, 22 AVAILABLE, 23 }; 24 25 struct msg_parser { 26 spinlock_t lock; 27 enum msg_parser_state state; 28 unsigned int interval; 29 unsigned int message_count; 30 unsigned int fragment_pos; 31 unsigned int value_index; 32 u64 value; 33 struct snd_firewire_motu_command_dsp_m 34 }; 35 36 int snd_motu_command_dsp_message_parser_new(st 37 { 38 struct msg_parser *parser; 39 40 parser = devm_kzalloc(&motu->card->car 41 if (!parser) 42 return -ENOMEM; 43 spin_lock_init(&parser->lock); 44 motu->message_parser = parser; 45 46 return 0; 47 } 48 49 int snd_motu_command_dsp_message_parser_init(s 50 { 51 struct msg_parser *parser = motu->mess 52 53 parser->state = INITIALIZED; 54 55 // All of data blocks don't have messa 56 switch (sfc) { 57 case CIP_SFC_176400: 58 case CIP_SFC_192000: 59 parser->interval = 4; 60 break; 61 case CIP_SFC_88200: 62 case CIP_SFC_96000: 63 parser->interval = 2; 64 break; 65 case CIP_SFC_32000: 66 case CIP_SFC_44100: 67 case CIP_SFC_48000: 68 default: 69 parser->interval = 1; 70 break; 71 } 72 73 return 0; 74 } 75 76 #define FRAGMENT_POS 6 77 #define MIDI_BYTE_POS 7 78 #define MIDI_FLAG_POS 8 79 // One value of hardware meter consists of 4 m 80 #define FRAGMENTS_PER_VALUE 4 81 #define VALUES_AT_IMAGE_END 0xffff 82 83 void snd_motu_command_dsp_message_parser_parse 84 const 85 { 86 struct snd_motu *motu = container_of(s 87 unsigned int data_block_quadlets = s-> 88 struct msg_parser *parser = motu->mess 89 unsigned int interval = parser->interv 90 unsigned long flags; 91 int i; 92 93 spin_lock_irqsave(&parser->lock, flags 94 95 for (i = 0; i < count; ++i) { 96 __be32 *buffer = desc->ctx_pay 97 unsigned int data_blocks = des 98 int j; 99 100 desc = amdtp_stream_next_packe 101 102 for (j = 0; j < data_blocks; + 103 u8 *b = (u8 *)buffer; 104 buffer += data_block_q 105 106 switch (parser->state) 107 case INITIALIZED: 108 { 109 u8 fragment = 110 111 if (fragment > 112 parser 113 parser 114 parser 115 } 116 break; 117 } 118 case FRAGMENT_DETECTED 119 { 120 if (parser->me 121 u8 fra 122 123 parser 124 parser 125 126 if (pa 127 128 129 130 131 } 132 } 133 ++parser->mess 134 break; 135 } 136 case AVAILABLE: 137 default: 138 { 139 if (parser->me 140 u8 fra 141 142 parser 143 parser 144 ++pars 145 146 if (pa 147 148 149 150 151 152 153 154 155 156 157 } 158 159 if (pa 160 161 162 163 } 164 } 165 ++parser->mess 166 break; 167 } 168 } 169 } 170 } 171 172 spin_unlock_irqrestore(&parser->lock, 173 } 174 175 void snd_motu_command_dsp_message_parser_copy_ 176 struct 177 { 178 struct msg_parser *parser = motu->mess 179 unsigned long flags; 180 181 spin_lock_irqsave(&parser->lock, flags 182 memcpy(meter, &parser->meter, sizeof(* 183 spin_unlock_irqrestore(&parser->lock, 184 } 185
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.