blob: 83a54fc73a11e6bf91138aee3275a0de464a092c [file] [log] [blame]
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +09001/*
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>
Takashi Sakamoto3c961012014-12-09 00:10:43 +090021#include <sound/info.h>
Takashi Sakamoto05588d32014-12-09 00:10:48 +090022#include <sound/rawmidi.h>
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +090023
24#include "../lib.h"
25#include "../fcp.h"
26#include "../packets-buffer.h"
27#include "../iso-resources.h"
28#include "../amdtp.h"
29#include "../cmp.h"
30
31struct device_info {
32 const char *driver_name;
Takashi Sakamotofec7b752014-12-09 00:10:40 +090033 const char *vendor_name;
34 const char *model_name;
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +090035 unsigned int mixer_channels;
36 u8 mute_fb_id;
37 u8 volume_fb_id;
38};
39
Takashi Sakamoto5cd1d3f2014-12-09 00:10:42 +090040/* This is an arbitrary number for convinience. */
41#define SND_OXFW_STREAM_FORMAT_ENTRIES 10
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +090042struct snd_oxfw {
43 struct snd_card *card;
44 struct fw_unit *unit;
45 const struct device_info *device_info;
46 struct mutex mutex;
Takashi Sakamoto05588d32014-12-09 00:10:48 +090047 spinlock_t lock;
Takashi Sakamoto5cd1d3f2014-12-09 00:10:42 +090048
Takashi Sakamotob0ac0002014-12-09 00:10:46 +090049 bool has_output;
50 u8 *tx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES];
Takashi Sakamoto5cd1d3f2014-12-09 00:10:42 +090051 u8 *rx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES];
52 bool assumed;
Takashi Sakamotob0ac0002014-12-09 00:10:46 +090053 struct cmp_connection out_conn;
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +090054 struct cmp_connection in_conn;
Takashi Sakamotob0ac0002014-12-09 00:10:46 +090055 struct amdtp_stream tx_stream;
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +090056 struct amdtp_stream rx_stream;
Takashi Sakamotob0ac0002014-12-09 00:10:46 +090057 unsigned int capture_substreams;
58 unsigned int playback_substreams;
Takashi Sakamoto5cd1d3f2014-12-09 00:10:42 +090059
Takashi Sakamoto05588d32014-12-09 00:10:48 +090060 unsigned int midi_input_ports;
61 unsigned int midi_output_ports;
62
Takashi Sakamotoe2786ca2014-11-29 00:59:27 +090063 bool mute;
64 s16 volume[6];
65 s16 volume_min;
66 s16 volume_max;
67};
68
Takashi Sakamoto5b59d8092014-12-09 00:10:41 +090069/*
70 * AV/C Stream Format Information Specification 1.1 Working Draft
71 * (Apr 2005, 1394TA)
72 */
73int avc_stream_set_format(struct fw_unit *unit, enum avc_general_plug_dir dir,
74 unsigned int pid, u8 *format, unsigned int len);
75int avc_stream_get_format(struct fw_unit *unit,
76 enum avc_general_plug_dir dir, unsigned int pid,
77 u8 *buf, unsigned int *len, unsigned int eid);
78static inline int
79avc_stream_get_format_single(struct fw_unit *unit,
80 enum avc_general_plug_dir dir, unsigned int pid,
81 u8 *buf, unsigned int *len)
82{
83 return avc_stream_get_format(unit, dir, pid, buf, len, 0xff);
84}
85static inline int
86avc_stream_get_format_list(struct fw_unit *unit,
87 enum avc_general_plug_dir dir, unsigned int pid,
88 u8 *buf, unsigned int *len,
89 unsigned int eid)
90{
91 return avc_stream_get_format(unit, dir, pid, buf, len, eid);
92}
93
94/*
95 * AV/C Digital Interface Command Set General Specification 4.2
96 * (Sep 2004, 1394TA)
97 */
98int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate,
99 enum avc_general_plug_dir dir,
100 unsigned short pid);
101
Takashi Sakamotob0ac0002014-12-09 00:10:46 +0900102int snd_oxfw_stream_init_simplex(struct snd_oxfw *oxfw,
103 struct amdtp_stream *stream);
104int snd_oxfw_stream_start_simplex(struct snd_oxfw *oxfw,
105 struct amdtp_stream *stream,
106 unsigned int rate, unsigned int pcm_channels);
107void snd_oxfw_stream_stop_simplex(struct snd_oxfw *oxfw,
108 struct amdtp_stream *stream);
109void snd_oxfw_stream_destroy_simplex(struct snd_oxfw *oxfw,
110 struct amdtp_stream *stream);
111void snd_oxfw_stream_update_simplex(struct snd_oxfw *oxfw,
112 struct amdtp_stream *stream);
Takashi Sakamoto3713d932014-11-29 00:59:28 +0900113
Takashi Sakamoto5cd1d3f2014-12-09 00:10:42 +0900114struct snd_oxfw_stream_formation {
115 unsigned int rate;
116 unsigned int pcm;
117 unsigned int midi;
118};
119int snd_oxfw_stream_parse_format(u8 *format,
120 struct snd_oxfw_stream_formation *formation);
121int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw,
122 enum avc_general_plug_dir dir,
123 struct snd_oxfw_stream_formation *formation);
Takashi Sakamotob0ac0002014-12-09 00:10:46 +0900124
Takashi Sakamoto5cd1d3f2014-12-09 00:10:42 +0900125int snd_oxfw_stream_discover(struct snd_oxfw *oxfw);
126
Takashi Sakamoto3713d932014-11-29 00:59:28 +0900127int snd_oxfw_create_pcm(struct snd_oxfw *oxfw);
Takashi Sakamoto31514bf2014-11-29 00:59:29 +0900128
129int snd_oxfw_create_mixer(struct snd_oxfw *oxfw);
Takashi Sakamoto3c961012014-12-09 00:10:43 +0900130
131void snd_oxfw_proc_init(struct snd_oxfw *oxfw);
Takashi Sakamoto05588d32014-12-09 00:10:48 +0900132
133int snd_oxfw_create_midi(struct snd_oxfw *oxfw);