Commit | Line | Data |
---|---|---|
e2786ca6 TS |
1 | /* |
2 | * oxfw.h - a part of driver for OXFW970/971 based devices | |
3 | * | |
4 | * Copyright (c) Clemens Ladisch <clemens@ladisch.de> | |
5 | * Licensed under the terms of the GNU General Public License, version 2. | |
6 | */ | |
7 | ||
8 | #include <linux/device.h> | |
9 | #include <linux/firewire.h> | |
10 | #include <linux/firewire-constants.h> | |
11 | #include <linux/module.h> | |
12 | #include <linux/mod_devicetable.h> | |
13 | #include <linux/mutex.h> | |
14 | #include <linux/slab.h> | |
15 | ||
16 | #include <sound/control.h> | |
17 | #include <sound/core.h> | |
18 | #include <sound/initval.h> | |
19 | #include <sound/pcm.h> | |
20 | #include <sound/pcm_params.h> | |
3c96101f | 21 | #include <sound/info.h> |
e2786ca6 TS |
22 | |
23 | #include "../lib.h" | |
24 | #include "../fcp.h" | |
25 | #include "../packets-buffer.h" | |
26 | #include "../iso-resources.h" | |
27 | #include "../amdtp.h" | |
28 | #include "../cmp.h" | |
29 | ||
30 | struct device_info { | |
31 | const char *driver_name; | |
fec7b753 TS |
32 | const char *vendor_name; |
33 | const char *model_name; | |
e2786ca6 TS |
34 | unsigned int mixer_channels; |
35 | u8 mute_fb_id; | |
36 | u8 volume_fb_id; | |
37 | }; | |
38 | ||
5cd1d3f4 TS |
39 | /* This is an arbitrary number for convinience. */ |
40 | #define SND_OXFW_STREAM_FORMAT_ENTRIES 10 | |
e2786ca6 TS |
41 | struct snd_oxfw { |
42 | struct snd_card *card; | |
43 | struct fw_unit *unit; | |
44 | const struct device_info *device_info; | |
45 | struct mutex mutex; | |
5cd1d3f4 TS |
46 | |
47 | u8 *rx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES]; | |
48 | bool assumed; | |
e2786ca6 TS |
49 | struct cmp_connection in_conn; |
50 | struct amdtp_stream rx_stream; | |
5cd1d3f4 | 51 | |
e2786ca6 TS |
52 | bool mute; |
53 | s16 volume[6]; | |
54 | s16 volume_min; | |
55 | s16 volume_max; | |
56 | }; | |
57 | ||
5b59d809 TS |
58 | /* |
59 | * AV/C Stream Format Information Specification 1.1 Working Draft | |
60 | * (Apr 2005, 1394TA) | |
61 | */ | |
62 | int avc_stream_set_format(struct fw_unit *unit, enum avc_general_plug_dir dir, | |
63 | unsigned int pid, u8 *format, unsigned int len); | |
64 | int avc_stream_get_format(struct fw_unit *unit, | |
65 | enum avc_general_plug_dir dir, unsigned int pid, | |
66 | u8 *buf, unsigned int *len, unsigned int eid); | |
67 | static inline int | |
68 | avc_stream_get_format_single(struct fw_unit *unit, | |
69 | enum avc_general_plug_dir dir, unsigned int pid, | |
70 | u8 *buf, unsigned int *len) | |
71 | { | |
72 | return avc_stream_get_format(unit, dir, pid, buf, len, 0xff); | |
73 | } | |
74 | static inline int | |
75 | avc_stream_get_format_list(struct fw_unit *unit, | |
76 | enum avc_general_plug_dir dir, unsigned int pid, | |
77 | u8 *buf, unsigned int *len, | |
78 | unsigned int eid) | |
79 | { | |
80 | return avc_stream_get_format(unit, dir, pid, buf, len, eid); | |
81 | } | |
82 | ||
83 | /* | |
84 | * AV/C Digital Interface Command Set General Specification 4.2 | |
85 | * (Sep 2004, 1394TA) | |
86 | */ | |
87 | int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate, | |
88 | enum avc_general_plug_dir dir, | |
89 | unsigned short pid); | |
90 | ||
e2786ca6 | 91 | int snd_oxfw_stream_init_simplex(struct snd_oxfw *oxfw); |
f3699e2c TS |
92 | int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw, unsigned int rate, |
93 | unsigned int pcm_channels); | |
e2786ca6 TS |
94 | void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw); |
95 | void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw); | |
96 | void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw); | |
3713d93a | 97 | |
5cd1d3f4 TS |
98 | struct snd_oxfw_stream_formation { |
99 | unsigned int rate; | |
100 | unsigned int pcm; | |
101 | unsigned int midi; | |
102 | }; | |
103 | int snd_oxfw_stream_parse_format(u8 *format, | |
104 | struct snd_oxfw_stream_formation *formation); | |
105 | int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw, | |
106 | enum avc_general_plug_dir dir, | |
107 | struct snd_oxfw_stream_formation *formation); | |
108 | int snd_oxfw_stream_discover(struct snd_oxfw *oxfw); | |
109 | ||
3713d93a | 110 | int snd_oxfw_create_pcm(struct snd_oxfw *oxfw); |
31514bfb TS |
111 | |
112 | int snd_oxfw_create_mixer(struct snd_oxfw *oxfw); | |
3c96101f TS |
113 | |
114 | void snd_oxfw_proc_init(struct snd_oxfw *oxfw); |