Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * oxfw_proc.c - a part of driver for OXFW970/971 based devices
0004  *
0005  * Copyright (c) 2014 Takashi Sakamoto
0006  */
0007 
0008 #include "./oxfw.h"
0009 
0010 static void proc_read_formation(struct snd_info_entry *entry,
0011                 struct snd_info_buffer *buffer)
0012 {
0013     struct snd_oxfw *oxfw = entry->private_data;
0014     struct snd_oxfw_stream_formation formation, curr;
0015     u8 *format;
0016     char flag;
0017     int i, err;
0018 
0019     /* Show input. */
0020     err = snd_oxfw_stream_get_current_formation(oxfw,
0021                             AVC_GENERAL_PLUG_DIR_IN,
0022                             &curr);
0023     if (err < 0)
0024         return;
0025 
0026     snd_iprintf(buffer, "Input Stream to device:\n");
0027     snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
0028     for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
0029         format = oxfw->rx_stream_formats[i];
0030         if (format == NULL)
0031             continue;
0032 
0033         err = snd_oxfw_stream_parse_format(format, &formation);
0034         if (err < 0)
0035             continue;
0036 
0037         if (memcmp(&formation, &curr, sizeof(curr)) == 0)
0038             flag = '*';
0039         else
0040             flag = ' ';
0041 
0042         snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag,
0043                 formation.rate, formation.pcm, formation.midi);
0044     }
0045 
0046     if (!oxfw->has_output)
0047         return;
0048 
0049     /* Show output. */
0050     err = snd_oxfw_stream_get_current_formation(oxfw,
0051                             AVC_GENERAL_PLUG_DIR_OUT,
0052                             &curr);
0053     if (err < 0)
0054         return;
0055 
0056     snd_iprintf(buffer, "Output Stream from device:\n");
0057     snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
0058     for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
0059         format = oxfw->tx_stream_formats[i];
0060         if (format == NULL)
0061             continue;
0062 
0063         err = snd_oxfw_stream_parse_format(format, &formation);
0064         if (err < 0)
0065             continue;
0066 
0067         if (memcmp(&formation, &curr, sizeof(curr)) == 0)
0068             flag = '*';
0069         else
0070             flag = ' ';
0071 
0072         snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag,
0073                 formation.rate, formation.pcm, formation.midi);
0074     }
0075 }
0076 
0077 static void add_node(struct snd_oxfw *oxfw, struct snd_info_entry *root,
0078              const char *name,
0079              void (*op)(struct snd_info_entry *e,
0080                 struct snd_info_buffer *b))
0081 {
0082     struct snd_info_entry *entry;
0083 
0084     entry = snd_info_create_card_entry(oxfw->card, name, root);
0085     if (entry)
0086         snd_info_set_text_ops(entry, oxfw, op);
0087 }
0088 
0089 void snd_oxfw_proc_init(struct snd_oxfw *oxfw)
0090 {
0091     struct snd_info_entry *root;
0092 
0093     /*
0094      * All nodes are automatically removed at snd_card_disconnect(),
0095      * by following to link list.
0096      */
0097     root = snd_info_create_card_entry(oxfw->card, "firewire",
0098                       oxfw->card->proc_root);
0099     if (root == NULL)
0100         return;
0101     root->mode = S_IFDIR | 0555;
0102 
0103     add_node(oxfw, root, "formation", proc_read_formation);
0104 }