diff options
| author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2014-12-08 10:10:43 -0500 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2014-12-10 04:47:54 -0500 |
| commit | 3c96101f190020e91d413c5835f7a722fc007923 (patch) | |
| tree | 00aaf93b5806daa8c1f750e08c1ee50332a96747 | |
| parent | 5cd1d3f47a6321612a51ab88ffe8ef65120fcbe0 (diff) | |
ALSA: oxfw: Add proc interface for debugging purpose
This commit adds proc interface to get information about stream
formation. This commit also adds snd_oxfw_stream_get_current_formation()
to get current stream formation.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
| -rw-r--r-- | sound/firewire/oxfw/Makefile | 3 | ||||
| -rw-r--r-- | sound/firewire/oxfw/oxfw-proc.c | 84 | ||||
| -rw-r--r-- | sound/firewire/oxfw/oxfw-stream.c | 27 | ||||
| -rw-r--r-- | sound/firewire/oxfw/oxfw.c | 2 | ||||
| -rw-r--r-- | sound/firewire/oxfw/oxfw.h | 3 |
5 files changed, 118 insertions, 1 deletions
diff --git a/sound/firewire/oxfw/Makefile b/sound/firewire/oxfw/Makefile index b107134d11d5..e9297c638aa1 100644 --- a/sound/firewire/oxfw/Makefile +++ b/sound/firewire/oxfw/Makefile | |||
| @@ -1,2 +1,3 @@ | |||
| 1 | snd-oxfw-objs := oxfw-command.o oxfw-stream.o oxfw-control.o oxfw-pcm.o oxfw.o | 1 | snd-oxfw-objs := oxfw-command.o oxfw-stream.o oxfw-control.o oxfw-pcm.o \ |
| 2 | oxfw-proc.o oxfw.o | ||
| 2 | obj-m += snd-oxfw.o | 3 | obj-m += snd-oxfw.o |
diff --git a/sound/firewire/oxfw/oxfw-proc.c b/sound/firewire/oxfw/oxfw-proc.c new file mode 100644 index 000000000000..18e030572708 --- /dev/null +++ b/sound/firewire/oxfw/oxfw-proc.c | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | /* | ||
| 2 | * oxfw_proc.c - a part of driver for OXFW970/971 based devices | ||
| 3 | * | ||
| 4 | * Copyright (c) 2014 Takashi Sakamoto | ||
| 5 | * | ||
| 6 | * Licensed under the terms of the GNU General Public License, version 2. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #include "./oxfw.h" | ||
| 10 | |||
| 11 | static void proc_read_formation(struct snd_info_entry *entry, | ||
| 12 | struct snd_info_buffer *buffer) | ||
| 13 | { | ||
| 14 | struct snd_oxfw *oxfw = entry->private_data; | ||
| 15 | struct snd_oxfw_stream_formation formation, curr; | ||
| 16 | u8 *format; | ||
| 17 | char flag; | ||
| 18 | unsigned int i, err; | ||
| 19 | |||
| 20 | /* Show input. */ | ||
| 21 | err = snd_oxfw_stream_get_current_formation(oxfw, | ||
| 22 | AVC_GENERAL_PLUG_DIR_IN, | ||
| 23 | &curr); | ||
| 24 | if (err < 0) | ||
| 25 | return; | ||
| 26 | |||
| 27 | snd_iprintf(buffer, "Input Stream to device:\n"); | ||
| 28 | snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n"); | ||
| 29 | for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) { | ||
| 30 | format = oxfw->rx_stream_formats[i]; | ||
| 31 | if (format == NULL) | ||
| 32 | continue; | ||
| 33 | |||
| 34 | err = snd_oxfw_stream_parse_format(format, &formation); | ||
| 35 | if (err < 0) | ||
| 36 | continue; | ||
| 37 | |||
| 38 | if (memcmp(&formation, &curr, sizeof(curr)) == 0) | ||
| 39 | flag = '*'; | ||
| 40 | else | ||
| 41 | flag = ' '; | ||
| 42 | |||
| 43 | snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag, | ||
| 44 | formation.rate, formation.pcm, formation.midi); | ||
| 45 | } | ||
| 46 | |||
| 47 | } | ||
| 48 | |||
| 49 | static void add_node(struct snd_oxfw *oxfw, struct snd_info_entry *root, | ||
| 50 | const char *name, | ||
| 51 | void (*op)(struct snd_info_entry *e, | ||
| 52 | struct snd_info_buffer *b)) | ||
| 53 | { | ||
| 54 | struct snd_info_entry *entry; | ||
| 55 | |||
| 56 | entry = snd_info_create_card_entry(oxfw->card, name, root); | ||
| 57 | if (entry == NULL) | ||
| 58 | return; | ||
| 59 | |||
| 60 | snd_info_set_text_ops(entry, oxfw, op); | ||
| 61 | if (snd_info_register(entry) < 0) | ||
| 62 | snd_info_free_entry(entry); | ||
| 63 | } | ||
| 64 | |||
| 65 | void snd_oxfw_proc_init(struct snd_oxfw *oxfw) | ||
| 66 | { | ||
| 67 | struct snd_info_entry *root; | ||
| 68 | |||
| 69 | /* | ||
| 70 | * All nodes are automatically removed at snd_card_disconnect(), | ||
| 71 | * by following to link list. | ||
| 72 | */ | ||
| 73 | root = snd_info_create_card_entry(oxfw->card, "firewire", | ||
| 74 | oxfw->card->proc_root); | ||
| 75 | if (root == NULL) | ||
| 76 | return; | ||
| 77 | root->mode = S_IFDIR | S_IRUGO | S_IXUGO; | ||
| 78 | if (snd_info_register(root) < 0) { | ||
| 79 | snd_info_free_entry(root); | ||
| 80 | return; | ||
| 81 | } | ||
| 82 | |||
| 83 | add_node(oxfw, root, "formation", proc_read_formation); | ||
| 84 | } | ||
diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c index 17e3802e6ac2..210bf5a2f56e 100644 --- a/sound/firewire/oxfw/oxfw-stream.c +++ b/sound/firewire/oxfw/oxfw-stream.c | |||
| @@ -108,6 +108,33 @@ void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw) | |||
| 108 | amdtp_stream_update(&oxfw->rx_stream); | 108 | amdtp_stream_update(&oxfw->rx_stream); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, | ||
| 112 | enum avc_general_plug_dir dir, | ||
| 113 | struct snd_oxfw_stream_formation *formation) | ||
| 114 | { | ||
| 115 | u8 *format; | ||
| 116 | unsigned int len; | ||
| 117 | int err; | ||
| 118 | |||
| 119 | len = AVC_GENERIC_FRAME_MAXIMUM_BYTES; | ||
| 120 | format = kmalloc(len, GFP_KERNEL); | ||
| 121 | if (format == NULL) | ||
| 122 | return -ENOMEM; | ||
| 123 | |||
| 124 | err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len); | ||
| 125 | if (err < 0) | ||
| 126 | goto end; | ||
| 127 | if (len < 3) { | ||
| 128 | err = -EIO; | ||
| 129 | goto end; | ||
| 130 | } | ||
| 131 | |||
| 132 | err = snd_oxfw_stream_parse_format(format, formation); | ||
| 133 | end: | ||
| 134 | kfree(format); | ||
| 135 | return err; | ||
| 136 | } | ||
| 137 | |||
| 111 | /* | 138 | /* |
| 112 | * See Table 6.16 - AM824 Stream Format | 139 | * See Table 6.16 - AM824 Stream Format |
| 113 | * Figure 6.19 - format_information field for AM824 Compound | 140 | * Figure 6.19 - format_information field for AM824 Compound |
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c index a8f9062b2884..a70149ab511b 100644 --- a/sound/firewire/oxfw/oxfw.c +++ b/sound/firewire/oxfw/oxfw.c | |||
| @@ -101,6 +101,8 @@ static int oxfw_probe(struct fw_unit *unit, | |||
| 101 | if (err < 0) | 101 | if (err < 0) |
| 102 | goto error; | 102 | goto error; |
| 103 | 103 | ||
| 104 | snd_oxfw_proc_init(oxfw); | ||
| 105 | |||
| 104 | err = snd_oxfw_stream_init_simplex(oxfw); | 106 | err = snd_oxfw_stream_init_simplex(oxfw); |
| 105 | if (err < 0) | 107 | if (err < 0) |
| 106 | goto error; | 108 | goto error; |
diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index 9c3d3e352665..8c832ea6aae0 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <sound/initval.h> | 18 | #include <sound/initval.h> |
| 19 | #include <sound/pcm.h> | 19 | #include <sound/pcm.h> |
| 20 | #include <sound/pcm_params.h> | 20 | #include <sound/pcm_params.h> |
| 21 | #include <sound/info.h> | ||
| 21 | 22 | ||
| 22 | #include "../lib.h" | 23 | #include "../lib.h" |
| 23 | #include "../fcp.h" | 24 | #include "../fcp.h" |
| @@ -108,3 +109,5 @@ int snd_oxfw_stream_discover(struct snd_oxfw *oxfw); | |||
| 108 | int snd_oxfw_create_pcm(struct snd_oxfw *oxfw); | 109 | int snd_oxfw_create_pcm(struct snd_oxfw *oxfw); |
| 109 | 110 | ||
| 110 | int snd_oxfw_create_mixer(struct snd_oxfw *oxfw); | 111 | int snd_oxfw_create_mixer(struct snd_oxfw *oxfw); |
| 112 | |||
| 113 | void snd_oxfw_proc_init(struct snd_oxfw *oxfw); | ||
