Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * oxfw.h - a part of driver for OXFW970/971 based devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/firewire.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/firewire-constants.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/mod_devicetable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/sched/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <sound/control.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <sound/initval.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <sound/pcm_params.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <sound/info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <sound/rawmidi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <sound/firewire.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <sound/hwdep.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include "../lib.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include "../fcp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "../packets-buffer.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "../iso-resources.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "../amdtp-am824.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include "../cmp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) /* This is an arbitrary number for convinience. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define	SND_OXFW_STREAM_FORMAT_ENTRIES	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) struct snd_oxfw {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct snd_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct fw_unit *unit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	bool registered;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct delayed_work dwork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	bool wrong_dbs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	bool has_output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	bool has_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	u8 *tx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	u8 *rx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	bool assumed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct cmp_connection out_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	struct cmp_connection in_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	struct amdtp_stream tx_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct amdtp_stream rx_stream;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	unsigned int substreams_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	unsigned int midi_input_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	unsigned int midi_output_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	int dev_lock_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	bool dev_lock_changed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	wait_queue_head_t hwdep_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	const struct ieee1394_device_id *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	void *spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct amdtp_domain domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * AV/C Stream Format Information Specification 1.1 Working Draft
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * (Apr 2005, 1394TA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) int avc_stream_set_format(struct fw_unit *unit, enum avc_general_plug_dir dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			  unsigned int pid, u8 *format, unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) int avc_stream_get_format(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			  enum avc_general_plug_dir dir, unsigned int pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			  u8 *buf, unsigned int *len, unsigned int eid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) avc_stream_get_format_single(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			     enum avc_general_plug_dir dir, unsigned int pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			     u8 *buf, unsigned int *len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return avc_stream_get_format(unit, dir, pid, buf, len, 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) avc_stream_get_format_list(struct fw_unit *unit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			   enum avc_general_plug_dir dir, unsigned int pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			   u8 *buf, unsigned int *len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			   unsigned int eid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	return avc_stream_get_format(unit, dir, pid, buf, len, eid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * AV/C Digital Interface Command Set General Specification 4.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * (Sep 2004, 1394TA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 				enum avc_general_plug_dir dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 				unsigned short pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				   struct amdtp_stream *stream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 				   unsigned int rate, unsigned int pcm_channels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 				   unsigned int frames_per_period,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 				   unsigned int frames_per_buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct snd_oxfw_stream_formation {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	unsigned int rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	unsigned int pcm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	unsigned int midi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int snd_oxfw_stream_parse_format(u8 *format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 				 struct snd_oxfw_stream_formation *formation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 				enum avc_general_plug_dir dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 				struct snd_oxfw_stream_formation *formation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int snd_oxfw_stream_discover(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) void snd_oxfw_stream_lock_changed(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int snd_oxfw_stream_lock_try(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) void snd_oxfw_stream_lock_release(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int snd_oxfw_create_pcm(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) void snd_oxfw_proc_init(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) int snd_oxfw_create_midi(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int snd_oxfw_create_hwdep(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) int snd_oxfw_add_spkr(struct snd_oxfw *oxfw, bool is_lacie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int snd_oxfw_scs1x_add(struct snd_oxfw *oxfw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void snd_oxfw_scs1x_update(struct snd_oxfw *oxfw);