~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/firewire/motu/motu-register-dsp-message-parser.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/firewire/motu/motu-register-dsp-message-parser.c (Version linux-6.12-rc7) and /sound/firewire/motu/motu-register-dsp-message-parser.c (Version linux-5.16.20)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 //                                                  2 //
  3 // motu-register-dsp-message-parser.c - a part      3 // motu-register-dsp-message-parser.c - a part of driver for MOTU FireWire series
  4 //                                                  4 //
  5 // Copyright (c) 2021 Takashi Sakamoto <o-taka      5 // Copyright (c) 2021 Takashi Sakamoto <o-takashi@sakamocchi.jp>
  6                                                     6 
  7 // Below models allow software to configure th      7 // Below models allow software to configure their DSP functions by asynchronous transaction
  8 // to access their internal registers.              8 // to access their internal registers.
  9 // * 828 mk2                                        9 // * 828 mk2
 10 // * 896hd                                         10 // * 896hd
 11 // * Traveler                                      11 // * Traveler
 12 // * 8 pre                                         12 // * 8 pre
 13 // * Ultralite                                     13 // * Ultralite
 14 // * 4 pre                                         14 // * 4 pre
 15 // * Audio Express                                 15 // * Audio Express
 16 //                                                 16 //
 17 // Additionally, isochronous packets from the      17 // Additionally, isochronous packets from the above models include messages to notify state of
 18 // DSP. The messages are two set of 3 byte dat     18 // DSP. The messages are two set of 3 byte data in 2nd and 3rd quadlet of data block. When user
 19 // operates hardware components such as dial a     19 // operates hardware components such as dial and switch, corresponding messages are transferred.
 20 // The messages include Hardware metering and      20 // The messages include Hardware metering and MIDI messages as well.
 21                                                    21 
 22 #include "motu.h"                                  22 #include "motu.h"
 23                                                    23 
 24 #define MSG_FLAG_POS                    4          24 #define MSG_FLAG_POS                    4
 25 #define MSG_FLAG_TYPE_MASK              0xf8       25 #define MSG_FLAG_TYPE_MASK              0xf8
 26 #define MSG_FLAG_MIDI_MASK              0x01       26 #define MSG_FLAG_MIDI_MASK              0x01
 27 #define MSG_FLAG_MODEL_SPECIFIC_MASK    0x06       27 #define MSG_FLAG_MODEL_SPECIFIC_MASK    0x06
 28 #define   MSG_FLAG_8PRE                 0x00       28 #define   MSG_FLAG_8PRE                 0x00
 29 #define   MSG_FLAG_ULTRALITE            0x04       29 #define   MSG_FLAG_ULTRALITE            0x04
 30 #define   MSG_FLAG_TRAVELER             0x04       30 #define   MSG_FLAG_TRAVELER             0x04
 31 #define   MSG_FLAG_828MK2               0x04       31 #define   MSG_FLAG_828MK2               0x04
 32 #define   MSG_FLAG_896HD                0x04       32 #define   MSG_FLAG_896HD                0x04
 33 #define   MSG_FLAG_4PRE                 0x05 /     33 #define   MSG_FLAG_4PRE                 0x05 // MIDI mask is in 8th byte.
 34 #define   MSG_FLAG_AUDIOEXPRESS         0x05 /     34 #define   MSG_FLAG_AUDIOEXPRESS         0x05 // MIDI mask is in 8th byte.
 35 #define MSG_FLAG_TYPE_SHIFT             3          35 #define MSG_FLAG_TYPE_SHIFT             3
 36 #define MSG_VALUE_POS                   5          36 #define MSG_VALUE_POS                   5
 37 #define MSG_MIDI_BYTE_POS               6          37 #define MSG_MIDI_BYTE_POS               6
 38 #define MSG_METER_IDX_POS               7          38 #define MSG_METER_IDX_POS               7
 39                                                    39 
 40 // In 4 pre and Audio express, meter index is      40 // In 4 pre and Audio express, meter index is in 6th byte. MIDI flag is in 8th byte and MIDI byte
 41 // is in 7th byte.                                 41 // is in 7th byte.
 42 #define MSG_METER_IDX_POS_4PRE_AE       6          42 #define MSG_METER_IDX_POS_4PRE_AE       6
 43 #define MSG_MIDI_BYTE_POS_4PRE_AE       7          43 #define MSG_MIDI_BYTE_POS_4PRE_AE       7
 44 #define MSG_FLAG_MIDI_POS_4PRE_AE       8          44 #define MSG_FLAG_MIDI_POS_4PRE_AE       8
 45                                                    45 
 46 enum register_dsp_msg_type {                       46 enum register_dsp_msg_type {
 47         // Used for messages with no informati     47         // Used for messages with no information.
 48         INVALID = 0x00,                            48         INVALID = 0x00,
 49         MIXER_SELECT = 0x01,                       49         MIXER_SELECT = 0x01,
 50         MIXER_SRC_GAIN = 0x02,                     50         MIXER_SRC_GAIN = 0x02,
 51         MIXER_SRC_PAN = 0x03,                      51         MIXER_SRC_PAN = 0x03,
 52         MIXER_SRC_FLAG = 0x04,                     52         MIXER_SRC_FLAG = 0x04,
 53         MIXER_OUTPUT_PAIRED_VOLUME = 0x05,         53         MIXER_OUTPUT_PAIRED_VOLUME = 0x05,
 54         MIXER_OUTPUT_PAIRED_FLAG = 0x06,           54         MIXER_OUTPUT_PAIRED_FLAG = 0x06,
 55         MAIN_OUTPUT_PAIRED_VOLUME = 0x07,          55         MAIN_OUTPUT_PAIRED_VOLUME = 0x07,
 56         HP_OUTPUT_PAIRED_VOLUME = 0x08,            56         HP_OUTPUT_PAIRED_VOLUME = 0x08,
 57         HP_OUTPUT_PAIRED_ASSIGNMENT = 0x09,        57         HP_OUTPUT_PAIRED_ASSIGNMENT = 0x09,
 58         // Transferred by all models but the p     58         // Transferred by all models but the purpose is still unknown.
 59         UNKNOWN_0 = 0x0a,                          59         UNKNOWN_0 = 0x0a,
 60         // Specific to 828mk2, 896hd, Traveler     60         // Specific to 828mk2, 896hd, Traveler.
 61         UNKNOWN_2 = 0x0c,                          61         UNKNOWN_2 = 0x0c,
 62         // Specific to 828mk2, Traveler, and 8     62         // Specific to 828mk2, Traveler, and 896hd (not functional).
 63         LINE_INPUT_BOOST = 0x0d,                   63         LINE_INPUT_BOOST = 0x0d,
 64         // Specific to 828mk2, Traveler, and 8     64         // Specific to 828mk2, Traveler, and 896hd (not functional).
 65         LINE_INPUT_NOMINAL_LEVEL = 0x0e,           65         LINE_INPUT_NOMINAL_LEVEL = 0x0e,
 66         // Specific to Ultralite, 4 pre, Audio     66         // Specific to Ultralite, 4 pre, Audio express, and 8 pre (not functional).
 67         INPUT_GAIN_AND_INVERT = 0x15,              67         INPUT_GAIN_AND_INVERT = 0x15,
 68         // Specific to 4 pre, and Audio expres     68         // Specific to 4 pre, and Audio express.
 69         INPUT_FLAG = 0x16,                         69         INPUT_FLAG = 0x16,
 70         // Specific to 4 pre, and Audio expres     70         // Specific to 4 pre, and Audio express.
 71         MIXER_SRC_PAIRED_BALANCE = 0x17,           71         MIXER_SRC_PAIRED_BALANCE = 0x17,
 72         // Specific to 4 pre, and Audio expres     72         // Specific to 4 pre, and Audio express.
 73         MIXER_SRC_PAIRED_WIDTH = 0x18,             73         MIXER_SRC_PAIRED_WIDTH = 0x18,
 74         // Transferred by all models. This typ     74         // Transferred by all models. This type of message interposes the series of the other
 75         // messages. The message delivers sign     75         // messages. The message delivers signal level up to 96.0 kHz. In 828mk2, 896hd, and
 76         // Traveler, one of physical outputs i     76         // Traveler, one of physical outputs is selected for the message. The selection is done
 77         // by LSB one byte in asynchronous wri     77         // by LSB one byte in asynchronous write quadlet transaction to 0x'ffff'f000'0b2c.
 78         METER = 0x1f,                              78         METER = 0x1f,
 79 };                                                 79 };
 80                                                    80 
 81 #define EVENT_QUEUE_SIZE        16                 81 #define EVENT_QUEUE_SIZE        16
 82                                                    82 
 83 struct msg_parser {                                83 struct msg_parser {
 84         spinlock_t lock;                           84         spinlock_t lock;
 85         struct snd_firewire_motu_register_dsp_     85         struct snd_firewire_motu_register_dsp_meter meter;
 86         bool meter_pos_quirk;                      86         bool meter_pos_quirk;
 87                                                    87 
 88         struct snd_firewire_motu_register_dsp_     88         struct snd_firewire_motu_register_dsp_parameter param;
 89         u8 prev_mixer_src_type;                    89         u8 prev_mixer_src_type;
 90         u8 mixer_ch;                               90         u8 mixer_ch;
 91         u8 mixer_src_ch;                           91         u8 mixer_src_ch;
 92                                                    92 
 93         u8 input_ch;                               93         u8 input_ch;
 94         u8 prev_msg_type;                          94         u8 prev_msg_type;
 95                                                    95 
 96         u32 event_queue[EVENT_QUEUE_SIZE];         96         u32 event_queue[EVENT_QUEUE_SIZE];
 97         unsigned int push_pos;                     97         unsigned int push_pos;
 98         unsigned int pull_pos;                     98         unsigned int pull_pos;
 99 };                                                 99 };
100                                                   100 
101 int snd_motu_register_dsp_message_parser_new(s    101 int snd_motu_register_dsp_message_parser_new(struct snd_motu *motu)
102 {                                                 102 {
103         struct msg_parser *parser;                103         struct msg_parser *parser;
104         parser = devm_kzalloc(&motu->card->car    104         parser = devm_kzalloc(&motu->card->card_dev, sizeof(*parser), GFP_KERNEL);
105         if (!parser)                              105         if (!parser)
106                 return -ENOMEM;                   106                 return -ENOMEM;
107         spin_lock_init(&parser->lock);            107         spin_lock_init(&parser->lock);
108         if (motu->spec == &snd_motu_spec_4pre     108         if (motu->spec == &snd_motu_spec_4pre || motu->spec == &snd_motu_spec_audio_express)
109                 parser->meter_pos_quirk = true    109                 parser->meter_pos_quirk = true;
110         motu->message_parser = parser;            110         motu->message_parser = parser;
111         return 0;                                 111         return 0;
112 }                                                 112 }
113                                                   113 
114 int snd_motu_register_dsp_message_parser_init(    114 int snd_motu_register_dsp_message_parser_init(struct snd_motu *motu)
115 {                                                 115 {
116         struct msg_parser *parser = motu->mess    116         struct msg_parser *parser = motu->message_parser;
117                                                   117 
118         parser->prev_mixer_src_type = INVALID;    118         parser->prev_mixer_src_type = INVALID;
119         parser->mixer_ch = 0xff;                  119         parser->mixer_ch = 0xff;
120         parser->mixer_src_ch = 0xff;              120         parser->mixer_src_ch = 0xff;
121         parser->prev_msg_type = INVALID;          121         parser->prev_msg_type = INVALID;
122                                                   122 
123         return 0;                                 123         return 0;
124 }                                                 124 }
125                                                   125 
126 // Rough implementaion of queue without overru    126 // Rough implementaion of queue without overrun check.
127 static void queue_event(struct snd_motu *motu,    127 static void queue_event(struct snd_motu *motu, u8 msg_type, u8 identifier0, u8 identifier1, u8 val)
128 {                                                 128 {
129         struct msg_parser *parser = motu->mess    129         struct msg_parser *parser = motu->message_parser;
130         unsigned int pos = parser->push_pos;      130         unsigned int pos = parser->push_pos;
131         u32 entry;                                131         u32 entry;
132                                                   132 
133         if (!motu->hwdep || motu->hwdep->used     133         if (!motu->hwdep || motu->hwdep->used == 0)
134                 return;                           134                 return;
135                                                   135 
136         entry = (msg_type << 24) | (identifier    136         entry = (msg_type << 24) | (identifier0 << 16) | (identifier1 << 8) | val;
137         parser->event_queue[pos] = entry;         137         parser->event_queue[pos] = entry;
138                                                   138 
139         ++pos;                                    139         ++pos;
140         if (pos >= EVENT_QUEUE_SIZE)              140         if (pos >= EVENT_QUEUE_SIZE)
141                 pos = 0;                          141                 pos = 0;
142         parser->push_pos = pos;                   142         parser->push_pos = pos;
143 }                                                 143 }
144                                                   144 
145 void snd_motu_register_dsp_message_parser_pars !! 145 void snd_motu_register_dsp_message_parser_parse(struct snd_motu *motu, const struct pkt_desc *descs,
146                                                !! 146                                         unsigned int desc_count, unsigned int data_block_quadlets)
147 {                                                 147 {
148         struct snd_motu *motu = container_of(s << 
149         unsigned int data_block_quadlets = s-> << 
150         struct msg_parser *parser = motu->mess    148         struct msg_parser *parser = motu->message_parser;
151         bool meter_pos_quirk = parser->meter_p    149         bool meter_pos_quirk = parser->meter_pos_quirk;
152         unsigned int pos = parser->push_pos;      150         unsigned int pos = parser->push_pos;
153         unsigned long flags;                      151         unsigned long flags;
154         int i;                                    152         int i;
155                                                   153 
156         spin_lock_irqsave(&parser->lock, flags    154         spin_lock_irqsave(&parser->lock, flags);
157                                                   155 
158         for (i = 0; i < count; ++i) {          !! 156         for (i = 0; i < desc_count; ++i) {
                                                   >> 157                 const struct pkt_desc *desc = descs + i;
159                 __be32 *buffer = desc->ctx_pay    158                 __be32 *buffer = desc->ctx_payload;
160                 unsigned int data_blocks = des    159                 unsigned int data_blocks = desc->data_blocks;
161                 int j;                            160                 int j;
162                                                << 
163                 desc = amdtp_stream_next_packe << 
164                                                   161 
165                 for (j = 0; j < data_blocks; +    162                 for (j = 0; j < data_blocks; ++j) {
166                         u8 *b = (u8 *)buffer;     163                         u8 *b = (u8 *)buffer;
167                         u8 msg_type = (b[MSG_F    164                         u8 msg_type = (b[MSG_FLAG_POS] & MSG_FLAG_TYPE_MASK) >> MSG_FLAG_TYPE_SHIFT;
168                         u8 val = b[MSG_VALUE_P    165                         u8 val = b[MSG_VALUE_POS];
169                                                   166 
170                         buffer += data_block_q    167                         buffer += data_block_quadlets;
171                                                   168 
172                         switch (msg_type) {       169                         switch (msg_type) {
173                         case MIXER_SELECT:        170                         case MIXER_SELECT:
174                         {                         171                         {
175                                 u8 mixer_ch =     172                                 u8 mixer_ch = val / 0x20;
176                                 if (mixer_ch <    173                                 if (mixer_ch < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT) {
177                                         parser    174                                         parser->mixer_src_ch = 0;
178                                         parser    175                                         parser->mixer_ch = mixer_ch;
179                                 }                 176                                 }
180                                 break;            177                                 break;
181                         }                         178                         }
182                         case MIXER_SRC_GAIN:      179                         case MIXER_SRC_GAIN:
183                         case MIXER_SRC_PAN:       180                         case MIXER_SRC_PAN:
184                         case MIXER_SRC_FLAG:      181                         case MIXER_SRC_FLAG:
185                         case MIXER_SRC_PAIRED_    182                         case MIXER_SRC_PAIRED_BALANCE:
186                         case MIXER_SRC_PAIRED_    183                         case MIXER_SRC_PAIRED_WIDTH:
187                         {                         184                         {
188                                 struct snd_fir    185                                 struct snd_firewire_motu_register_dsp_parameter *param = &parser->param;
189                                 u8 mixer_ch =     186                                 u8 mixer_ch = parser->mixer_ch;
190                                 u8 mixer_src_c    187                                 u8 mixer_src_ch = parser->mixer_src_ch;
191                                                   188 
192                                 if (msg_type !    189                                 if (msg_type != parser->prev_mixer_src_type)
193                                         mixer_    190                                         mixer_src_ch = 0;
194                                 else              191                                 else
195                                         ++mixe    192                                         ++mixer_src_ch;
196                                 parser->prev_m    193                                 parser->prev_mixer_src_type = msg_type;
197                                                   194 
198                                 if (mixer_ch <    195                                 if (mixer_ch < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT &&
199                                     mixer_src_    196                                     mixer_src_ch < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_SRC_COUNT) {
200                                         u8 mix    197                                         u8 mixer_ch = parser->mixer_ch;
201                                                   198 
202                                         switch    199                                         switch (msg_type) {
203                                         case M    200                                         case MIXER_SRC_GAIN:
204                                                   201                                                 if (param->mixer.source[mixer_ch].gain[mixer_src_ch] != val) {
205                                                   202                                                         queue_event(motu, msg_type, mixer_ch, mixer_src_ch, val);
206                                                   203                                                         param->mixer.source[mixer_ch].gain[mixer_src_ch] = val;
207                                                   204                                                 }
208                                                   205                                                 break;
209                                         case M    206                                         case MIXER_SRC_PAN:
210                                                   207                                                 if (param->mixer.source[mixer_ch].pan[mixer_src_ch] != val) {
211                                                   208                                                         queue_event(motu, msg_type, mixer_ch, mixer_src_ch, val);
212                                                   209                                                         param->mixer.source[mixer_ch].pan[mixer_src_ch] = val;
213                                                   210                                                 }
214                                                   211                                                 break;
215                                         case M    212                                         case MIXER_SRC_FLAG:
216                                                   213                                                 if (param->mixer.source[mixer_ch].flag[mixer_src_ch] != val) {
217                                                   214                                                         queue_event(motu, msg_type, mixer_ch, mixer_src_ch, val);
218                                                   215                                                         param->mixer.source[mixer_ch].flag[mixer_src_ch] = val;
219                                                   216                                                 }
220                                                   217                                                 break;
221                                         case M    218                                         case MIXER_SRC_PAIRED_BALANCE:
222                                                   219                                                 if (param->mixer.source[mixer_ch].paired_balance[mixer_src_ch] != val) {
223                                                   220                                                         queue_event(motu, msg_type, mixer_ch, mixer_src_ch, val);
224                                                   221                                                         param->mixer.source[mixer_ch].paired_balance[mixer_src_ch] = val;
225                                                   222                                                 }
226                                                   223                                                 break;
227                                         case M    224                                         case MIXER_SRC_PAIRED_WIDTH:
228                                                   225                                                 if (param->mixer.source[mixer_ch].paired_width[mixer_src_ch] != val) {
229                                                   226                                                         queue_event(motu, msg_type, mixer_ch, mixer_src_ch, val);
230                                                   227                                                         param->mixer.source[mixer_ch].paired_width[mixer_src_ch] = val;
231                                                   228                                                 }
232                                                   229                                                 break;
233                                         defaul    230                                         default:
234                                                   231                                                 break;
235                                         }         232                                         }
236                                                   233 
237                                         parser    234                                         parser->mixer_src_ch = mixer_src_ch;
238                                 }                 235                                 }
239                                 break;            236                                 break;
240                         }                         237                         }
241                         case MIXER_OUTPUT_PAIR    238                         case MIXER_OUTPUT_PAIRED_VOLUME:
242                         case MIXER_OUTPUT_PAIR    239                         case MIXER_OUTPUT_PAIRED_FLAG:
243                         {                         240                         {
244                                 struct snd_fir    241                                 struct snd_firewire_motu_register_dsp_parameter *param = &parser->param;
245                                 u8 mixer_ch =     242                                 u8 mixer_ch = parser->mixer_ch;
246                                                   243 
247                                 if (mixer_ch <    244                                 if (mixer_ch < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_MIXER_COUNT) {
248                                         switch    245                                         switch (msg_type) {
249                                         case M    246                                         case MIXER_OUTPUT_PAIRED_VOLUME:
250                                                   247                                                 if (param->mixer.output.paired_volume[mixer_ch] != val) {
251                                                   248                                                         queue_event(motu, msg_type, mixer_ch, 0, val);
252                                                   249                                                         param->mixer.output.paired_volume[mixer_ch] = val;
253                                                   250                                                 }
254                                                   251                                                 break;
255                                         case M    252                                         case MIXER_OUTPUT_PAIRED_FLAG:
256                                                   253                                                 if (param->mixer.output.paired_flag[mixer_ch] != val) {
257                                                   254                                                         queue_event(motu, msg_type, mixer_ch, 0, val);
258                                                   255                                                         param->mixer.output.paired_flag[mixer_ch] = val;
259                                                   256                                                 }
260                                                   257                                                 break;
261                                         defaul    258                                         default:
262                                                   259                                                 break;
263                                         }         260                                         }
264                                 }                 261                                 }
265                                 break;            262                                 break;
266                         }                         263                         }
267                         case MAIN_OUTPUT_PAIRE    264                         case MAIN_OUTPUT_PAIRED_VOLUME:
268                                 if (parser->pa    265                                 if (parser->param.output.main_paired_volume != val) {
269                                         queue_    266                                         queue_event(motu, msg_type, 0, 0, val);
270                                         parser    267                                         parser->param.output.main_paired_volume = val;
271                                 }                 268                                 }
272                                 break;            269                                 break;
273                         case HP_OUTPUT_PAIRED_    270                         case HP_OUTPUT_PAIRED_VOLUME:
274                                 if (parser->pa    271                                 if (parser->param.output.hp_paired_volume != val) {
275                                         queue_    272                                         queue_event(motu, msg_type, 0, 0, val);
276                                         parser    273                                         parser->param.output.hp_paired_volume = val;
277                                 }                 274                                 }
278                                 break;            275                                 break;
279                         case HP_OUTPUT_PAIRED_    276                         case HP_OUTPUT_PAIRED_ASSIGNMENT:
280                                 if (parser->pa    277                                 if (parser->param.output.hp_paired_assignment != val) {
281                                         queue_    278                                         queue_event(motu, msg_type, 0, 0, val);
282                                         parser    279                                         parser->param.output.hp_paired_assignment = val;
283                                 }                 280                                 }
284                                 break;            281                                 break;
285                         case LINE_INPUT_BOOST:    282                         case LINE_INPUT_BOOST:
286                                 if (parser->pa    283                                 if (parser->param.line_input.boost_flag != val) {
287                                         queue_    284                                         queue_event(motu, msg_type, 0, 0, val);
288                                         parser    285                                         parser->param.line_input.boost_flag = val;
289                                 }                 286                                 }
290                                 break;            287                                 break;
291                         case LINE_INPUT_NOMINA    288                         case LINE_INPUT_NOMINAL_LEVEL:
292                                 if (parser->pa    289                                 if (parser->param.line_input.nominal_level_flag != val) {
293                                         queue_    290                                         queue_event(motu, msg_type, 0, 0, val);
294                                         parser    291                                         parser->param.line_input.nominal_level_flag = val;
295                                 }                 292                                 }
296                                 break;            293                                 break;
297                         case INPUT_GAIN_AND_IN    294                         case INPUT_GAIN_AND_INVERT:
298                         case INPUT_FLAG:          295                         case INPUT_FLAG:
299                         {                         296                         {
300                                 struct snd_fir    297                                 struct snd_firewire_motu_register_dsp_parameter *param = &parser->param;
301                                 u8 input_ch =     298                                 u8 input_ch = parser->input_ch;
302                                                   299 
303                                 if (parser->pr    300                                 if (parser->prev_msg_type != msg_type)
304                                         input_    301                                         input_ch = 0;
305                                 else              302                                 else
306                                         ++inpu    303                                         ++input_ch;
307                                                   304 
308                                 if (input_ch <    305                                 if (input_ch < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_INPUT_COUNT) {
309                                         switch    306                                         switch (msg_type) {
310                                         case I    307                                         case INPUT_GAIN_AND_INVERT:
311                                                   308                                                 if (param->input.gain_and_invert[input_ch] != val) {
312                                                   309                                                         queue_event(motu, msg_type, input_ch, 0, val);
313                                                   310                                                         param->input.gain_and_invert[input_ch] = val;
314                                                   311                                                 }
315                                                   312                                                 break;
316                                         case I    313                                         case INPUT_FLAG:
317                                                   314                                                 if (param->input.flag[input_ch] != val) {
318                                                   315                                                         queue_event(motu, msg_type, input_ch, 0, val);
319                                                   316                                                         param->input.flag[input_ch] = val;
320                                                   317                                                 }
321                                                   318                                                 break;
322                                         defaul    319                                         default:
323                                                   320                                                 break;
324                                         }         321                                         }
325                                         parser    322                                         parser->input_ch = input_ch;
326                                 }                 323                                 }
327                                 break;            324                                 break;
328                         }                         325                         }
329                         case UNKNOWN_0:           326                         case UNKNOWN_0:
330                         case UNKNOWN_2:           327                         case UNKNOWN_2:
331                                 break;            328                                 break;
332                         case METER:               329                         case METER:
333                         {                         330                         {
334                                 u8 pos;           331                                 u8 pos;
335                                                   332 
336                                 if (!meter_pos    333                                 if (!meter_pos_quirk)
337                                         pos =     334                                         pos = b[MSG_METER_IDX_POS];
338                                 else              335                                 else
339                                         pos =     336                                         pos = b[MSG_METER_IDX_POS_4PRE_AE];
340                                                   337 
341                                 if (pos < SNDR    338                                 if (pos < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_INPUT_COUNT) {
342                                         parser    339                                         parser->meter.data[pos] = val;
343                                 } else if (pos    340                                 } else if (pos >= 0x80) {
344                                         pos -=    341                                         pos -= (0x80 - SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_INPUT_COUNT);
345                                                   342 
346                                         if (po    343                                         if (pos < SNDRV_FIREWIRE_MOTU_REGISTER_DSP_METER_COUNT)
347                                                   344                                                 parser->meter.data[pos] = val;
348                                 }                 345                                 }
349                                                   346 
350                                 // The message    347                                 // The message for meter is interruptible to the series of other
351                                 // types of me    348                                 // types of messages. Don't cache it.
352                                 fallthrough;      349                                 fallthrough;
353                         }                         350                         }
354                         case INVALID:             351                         case INVALID:
355                         default:                  352                         default:
356                                 // Don't cache    353                                 // Don't cache it.
357                                 continue;         354                                 continue;
358                         }                         355                         }
359                                                   356 
360                         parser->prev_msg_type     357                         parser->prev_msg_type = msg_type;
361                 }                                 358                 }
362         }                                         359         }
363                                                   360 
364         if (pos != parser->push_pos)              361         if (pos != parser->push_pos)
365                 wake_up(&motu->hwdep_wait);       362                 wake_up(&motu->hwdep_wait);
366                                                   363 
367         spin_unlock_irqrestore(&parser->lock,     364         spin_unlock_irqrestore(&parser->lock, flags);
368 }                                                 365 }
369                                                   366 
370 void snd_motu_register_dsp_message_parser_copy    367 void snd_motu_register_dsp_message_parser_copy_meter(struct snd_motu *motu,
371                                                   368                                                 struct snd_firewire_motu_register_dsp_meter *meter)
372 {                                                 369 {
373         struct msg_parser *parser = motu->mess    370         struct msg_parser *parser = motu->message_parser;
374         unsigned long flags;                      371         unsigned long flags;
375                                                   372 
376         spin_lock_irqsave(&parser->lock, flags    373         spin_lock_irqsave(&parser->lock, flags);
377         memcpy(meter, &parser->meter, sizeof(*    374         memcpy(meter, &parser->meter, sizeof(*meter));
378         spin_unlock_irqrestore(&parser->lock,     375         spin_unlock_irqrestore(&parser->lock, flags);
379 }                                                 376 }
380                                                   377 
381 void snd_motu_register_dsp_message_parser_copy    378 void snd_motu_register_dsp_message_parser_copy_parameter(struct snd_motu *motu,
382                                         struct    379                                         struct snd_firewire_motu_register_dsp_parameter *param)
383 {                                                 380 {
384         struct msg_parser *parser = motu->mess    381         struct msg_parser *parser = motu->message_parser;
385         unsigned long flags;                      382         unsigned long flags;
386                                                   383 
387         spin_lock_irqsave(&parser->lock, flags    384         spin_lock_irqsave(&parser->lock, flags);
388         memcpy(param, &parser->param, sizeof(*    385         memcpy(param, &parser->param, sizeof(*param));
389         spin_unlock_irqrestore(&parser->lock,     386         spin_unlock_irqrestore(&parser->lock, flags);
390 }                                                 387 }
391                                                   388 
392 unsigned int snd_motu_register_dsp_message_par    389 unsigned int snd_motu_register_dsp_message_parser_count_event(struct snd_motu *motu)
393 {                                                 390 {
394         struct msg_parser *parser = motu->mess    391         struct msg_parser *parser = motu->message_parser;
395                                                   392 
396         if (parser->pull_pos > parser->push_po    393         if (parser->pull_pos > parser->push_pos)
397                 return EVENT_QUEUE_SIZE - pars    394                 return EVENT_QUEUE_SIZE - parser->pull_pos + parser->push_pos;
398         else                                      395         else
399                 return parser->push_pos - pars    396                 return parser->push_pos - parser->pull_pos;
400 }                                                 397 }
401                                                   398 
402 bool snd_motu_register_dsp_message_parser_copy    399 bool snd_motu_register_dsp_message_parser_copy_event(struct snd_motu *motu, u32 *event)
403 {                                                 400 {
404         struct msg_parser *parser = motu->mess    401         struct msg_parser *parser = motu->message_parser;
405         unsigned int pos = parser->pull_pos;      402         unsigned int pos = parser->pull_pos;
406         unsigned long flags;                      403         unsigned long flags;
407                                                   404 
408         if (pos == parser->push_pos)              405         if (pos == parser->push_pos)
409                 return false;                     406                 return false;
410                                                   407 
411         spin_lock_irqsave(&parser->lock, flags    408         spin_lock_irqsave(&parser->lock, flags);
412                                                   409 
413         *event = parser->event_queue[pos];        410         *event = parser->event_queue[pos];
414                                                   411 
415         ++pos;                                    412         ++pos;
416         if (pos >= EVENT_QUEUE_SIZE)              413         if (pos >= EVENT_QUEUE_SIZE)
417                 pos = 0;                          414                 pos = 0;
418         parser->pull_pos = pos;                   415         parser->pull_pos = pos;
419                                                   416 
420         spin_unlock_irqrestore(&parser->lock,     417         spin_unlock_irqrestore(&parser->lock, flags);
421                                                   418 
422         return true;                              419         return true;
423 }                                                 420 }
424                                                   421 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php