2 * digi00x-transaction.c - a part of driver for Digidesign Digi 002/003 family
4 * Copyright (c) 2014-2015 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
9 #include <sound/asound.h>
12 static void handle_unknown_message(struct snd_dg00x
*dg00x
,
13 unsigned long long offset
, __be32
*buf
)
17 spin_lock_irqsave(&dg00x
->lock
, flags
);
18 dg00x
->msg
= be32_to_cpu(*buf
);
19 spin_unlock_irqrestore(&dg00x
->lock
, flags
);
21 wake_up(&dg00x
->hwdep_wait
);
24 static void handle_message(struct fw_card
*card
, struct fw_request
*request
,
25 int tcode
, int destination
, int source
,
26 int generation
, unsigned long long offset
,
27 void *data
, size_t length
, void *callback_data
)
29 struct snd_dg00x
*dg00x
= callback_data
;
30 __be32
*buf
= (__be32
*)data
;
32 fw_send_response(card
, request
, RCODE_COMPLETE
);
34 if (offset
== dg00x
->async_handler
.offset
)
35 handle_unknown_message(dg00x
, offset
, buf
);
38 int snd_dg00x_transaction_reregister(struct snd_dg00x
*dg00x
)
40 struct fw_device
*device
= fw_parent_device(dg00x
->unit
);
43 /* Unknown. 4bytes. */
44 data
[0] = cpu_to_be32((device
->card
->node_id
<< 16) |
45 (dg00x
->async_handler
.offset
>> 32));
46 data
[1] = cpu_to_be32(dg00x
->async_handler
.offset
);
47 return snd_fw_transaction(dg00x
->unit
, TCODE_WRITE_BLOCK_REQUEST
,
48 DG00X_ADDR_BASE
+ DG00X_OFFSET_MESSAGE_ADDR
,
49 &data
, sizeof(data
), 0);
52 void snd_dg00x_transaction_unregister(struct snd_dg00x
*dg00x
)
54 if (dg00x
->async_handler
.callback_data
== NULL
)
57 fw_core_remove_address_handler(&dg00x
->async_handler
);
59 dg00x
->async_handler
.callback_data
= NULL
;
62 int snd_dg00x_transaction_register(struct snd_dg00x
*dg00x
)
64 static const struct fw_address_region resp_register_region
= {
65 .start
= 0xffffe0000000ull
,
66 .end
= 0xffffe000ffffull
,
70 dg00x
->async_handler
.length
= 4;
71 dg00x
->async_handler
.address_callback
= handle_message
;
72 dg00x
->async_handler
.callback_data
= dg00x
;
74 err
= fw_core_add_address_handler(&dg00x
->async_handler
,
75 &resp_register_region
);
79 err
= snd_dg00x_transaction_reregister(dg00x
);
81 snd_dg00x_transaction_unregister(dg00x
);