diff options
Diffstat (limited to 'sound/firewire/oxfw/oxfw-scs1x.c')
-rw-r--r-- | sound/firewire/oxfw/oxfw-scs1x.c | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/sound/firewire/oxfw/oxfw-scs1x.c b/sound/firewire/oxfw/oxfw-scs1x.c index 34db0d0957c5..32a7b673cbc8 100644 --- a/sound/firewire/oxfw/oxfw-scs1x.c +++ b/sound/firewire/oxfw/oxfw-scs1x.c | |||
@@ -9,18 +9,81 @@ | |||
9 | 9 | ||
10 | #include "oxfw.h" | 10 | #include "oxfw.h" |
11 | 11 | ||
12 | #define HSS1394_ADDRESS 0xc007dedadadaULL | ||
13 | #define HSS1394_MAX_PACKET_SIZE 64 | ||
14 | #define HSS1394_TAG_CHANGE_ADDRESS 0xf1 | ||
15 | |||
16 | struct fw_scs1x { | ||
17 | struct fw_address_handler hss_handler; | ||
18 | }; | ||
19 | |||
20 | static void handle_hss(struct fw_card *card, struct fw_request *request, | ||
21 | int tcode, int destination, int source, int generation, | ||
22 | unsigned long long offset, void *data, size_t length, | ||
23 | void *callback_data) | ||
24 | { | ||
25 | fw_send_response(card, request, RCODE_COMPLETE); | ||
26 | } | ||
27 | |||
28 | static int register_address(struct snd_oxfw *oxfw) | ||
29 | { | ||
30 | struct fw_scs1x *scs = oxfw->spec; | ||
31 | __be64 data; | ||
32 | |||
33 | data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) | | ||
34 | scs->hss_handler.offset); | ||
35 | return snd_fw_transaction(oxfw->unit, TCODE_WRITE_BLOCK_REQUEST, | ||
36 | HSS1394_ADDRESS, &data, sizeof(data), 0); | ||
37 | } | ||
38 | |||
39 | static void remove_scs1x(struct snd_rawmidi *rmidi) | ||
40 | { | ||
41 | struct fw_scs1x *scs = rmidi->private_data; | ||
42 | |||
43 | fw_core_remove_address_handler(&scs->hss_handler); | ||
44 | } | ||
45 | |||
46 | void snd_oxfw_scs1x_update(struct snd_oxfw *oxfw) | ||
47 | { | ||
48 | register_address(oxfw); | ||
49 | } | ||
50 | |||
12 | int snd_oxfw_scs1x_add(struct snd_oxfw *oxfw) | 51 | int snd_oxfw_scs1x_add(struct snd_oxfw *oxfw) |
13 | { | 52 | { |
14 | struct snd_rawmidi *rmidi; | 53 | struct snd_rawmidi *rmidi; |
54 | struct fw_scs1x *scs; | ||
15 | int err; | 55 | int err; |
16 | 56 | ||
57 | scs = kzalloc(sizeof(struct fw_scs1x), GFP_KERNEL); | ||
58 | if (scs == NULL) | ||
59 | return -ENOMEM; | ||
60 | oxfw->spec = scs; | ||
61 | |||
62 | /* Allocate own handler for imcoming asynchronous transaction. */ | ||
63 | scs->hss_handler.length = HSS1394_MAX_PACKET_SIZE; | ||
64 | scs->hss_handler.address_callback = handle_hss; | ||
65 | scs->hss_handler.callback_data = scs; | ||
66 | err = fw_core_add_address_handler(&scs->hss_handler, | ||
67 | &fw_high_memory_region); | ||
68 | if (err < 0) | ||
69 | return err; | ||
70 | |||
71 | err = register_address(oxfw); | ||
72 | if (err < 0) | ||
73 | goto err_allocated; | ||
74 | |||
17 | /* Use unique name for backward compatibility to scs1x module. */ | 75 | /* Use unique name for backward compatibility to scs1x module. */ |
18 | err = snd_rawmidi_new(oxfw->card, "SCS.1x", 0, 0, 0, &rmidi); | 76 | err = snd_rawmidi_new(oxfw->card, "SCS.1x", 0, 0, 0, &rmidi); |
19 | if (err < 0) | 77 | if (err < 0) |
20 | return err; | 78 | goto err_allocated; |
79 | rmidi->private_data = scs; | ||
80 | rmidi->private_free = remove_scs1x; | ||
21 | 81 | ||
22 | snprintf(rmidi->name, sizeof(rmidi->name), | 82 | snprintf(rmidi->name, sizeof(rmidi->name), |
23 | "%s MIDI", oxfw->card->shortname); | 83 | "%s MIDI", oxfw->card->shortname); |
24 | 84 | ||
85 | return 0; | ||
86 | err_allocated: | ||
87 | fw_core_remove_address_handler(&scs->hss_handler); | ||
25 | return err; | 88 | return err; |
26 | } | 89 | } |