linux/drivers/usb/gadget/function/f_uac2.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * f_uac2.c -- USB Audio Class 2.0 Function
 *
 * Copyright (C) 2011
 *    Yadwinder Singh ([email protected])
 *    Jaswinder Singh ([email protected])
 *
 * Copyright (C) 2020
 *    Ruslan Bilovol ([email protected])
 */

#include <linux/usb/audio.h>
#include <linux/usb/audio-v2.h>
#include <linux/module.h>

#include "u_audio.h"

#include "u_uac2.h"

/* UAC2 spec: 4.1 Audio Channel Cluster Descriptor */
#define UAC2_CHANNEL_MASK

/*
 * The driver implements a simple UAC_2 topology.
 * USB-OUT -> IT_1 -> FU -> OT_3 -> ALSA_Capture
 * ALSA_Playback -> IT_2 -> FU -> OT_4 -> USB-IN
 * Capture and Playback sampling rates are independently
 *  controlled by two clock sources :
 *    CLK_5 := c_srate, and CLK_6 := p_srate
 */
#define USB_OUT_CLK_ID
#define USB_IN_CLK_ID
#define USB_OUT_FU_ID
#define USB_IN_FU_ID

#define CONTROL_ABSENT
#define CONTROL_RDONLY
#define CONTROL_RDWR

#define CLK_FREQ_CTRL
#define CLK_VLD_CTRL
#define FU_MUTE_CTRL
#define FU_VOL_CTRL

#define COPY_CTRL
#define CONN_CTRL
#define OVRLD_CTRL
#define CLSTR_CTRL
#define UNFLW_CTRL
#define OVFLW_CTRL

#define EPIN_EN(_opts)
#define EPOUT_EN(_opts)
#define FUIN_EN(_opts)
#define FUOUT_EN(_opts)
#define EPOUT_FBACK_IN_EN(_opts)

struct f_uac2 {};

static inline struct f_uac2 *func_to_uac2(struct usb_function *f)
{}

static inline
struct f_uac2_opts *g_audio_to_uac2_opts(struct g_audio *agdev)
{}

static int afunc_notify(struct g_audio *agdev, int unit_id, int cs);

/* --------- USB Function Interface ------------- */

enum {};

static struct usb_string strings_fn[NUM_STR_DESCRIPTORS + 1] =;

static const char *const speed_names[] =;

static struct usb_gadget_strings str_fn =;

static struct usb_gadget_strings *fn_strings[] =;

static struct usb_interface_assoc_descriptor iad_desc =;

/* Audio Control Interface */
static struct usb_interface_descriptor std_ac_if_desc =;

/* Clock source for IN traffic */
static struct uac_clock_source_descriptor in_clk_src_desc =;

/* Clock source for OUT traffic */
static struct uac_clock_source_descriptor out_clk_src_desc =;

/* Input Terminal for USB_OUT */
static struct uac2_input_terminal_descriptor usb_out_it_desc =;

/* Input Terminal for I/O-In */
static struct uac2_input_terminal_descriptor io_in_it_desc =;

/* Ouput Terminal for USB_IN */
static struct uac2_output_terminal_descriptor usb_in_ot_desc =;

/* Ouput Terminal for I/O-Out */
static struct uac2_output_terminal_descriptor io_out_ot_desc =;

static struct uac2_feature_unit_descriptor *in_feature_unit_desc;
static struct uac2_feature_unit_descriptor *out_feature_unit_desc;

static struct uac2_ac_header_descriptor ac_hdr_desc =;

/* AC IN Interrupt Endpoint */
static struct usb_endpoint_descriptor fs_ep_int_desc =;

static struct usb_endpoint_descriptor hs_ep_int_desc =;

static struct usb_endpoint_descriptor ss_ep_int_desc =;

static struct usb_ss_ep_comp_descriptor ss_ep_int_desc_comp =;

/* Audio Streaming OUT Interface - Alt0 */
static struct usb_interface_descriptor std_as_out_if0_desc =;

/* Audio Streaming OUT Interface - Alt1 */
static struct usb_interface_descriptor std_as_out_if1_desc =;

/* Audio Stream OUT Intface Desc */
static struct uac2_as_header_descriptor as_out_hdr_desc =;

/* Audio USB_OUT Format */
static struct uac2_format_type_i_descriptor as_out_fmt1_desc =;

/* STD AS ISO OUT Endpoint */
static struct usb_endpoint_descriptor fs_epout_desc =;

static struct usb_endpoint_descriptor hs_epout_desc =;

static struct usb_endpoint_descriptor ss_epout_desc =;

static struct usb_ss_ep_comp_descriptor ss_epout_desc_comp =;

/* CS AS ISO OUT Endpoint */
static struct uac2_iso_endpoint_descriptor as_iso_out_desc =;

/* STD AS ISO IN Feedback Endpoint */
static struct usb_endpoint_descriptor fs_epin_fback_desc =;

static struct usb_endpoint_descriptor hs_epin_fback_desc =;

static struct usb_endpoint_descriptor ss_epin_fback_desc =;

static struct usb_ss_ep_comp_descriptor ss_epin_fback_desc_comp =;


/* Audio Streaming IN Interface - Alt0 */
static struct usb_interface_descriptor std_as_in_if0_desc =;

/* Audio Streaming IN Interface - Alt1 */
static struct usb_interface_descriptor std_as_in_if1_desc =;

/* Audio Stream IN Intface Desc */
static struct uac2_as_header_descriptor as_in_hdr_desc =;

/* Audio USB_IN Format */
static struct uac2_format_type_i_descriptor as_in_fmt1_desc =;

/* STD AS ISO IN Endpoint */
static struct usb_endpoint_descriptor fs_epin_desc =;

static struct usb_endpoint_descriptor hs_epin_desc =;

static struct usb_endpoint_descriptor ss_epin_desc =;

static struct usb_ss_ep_comp_descriptor ss_epin_desc_comp =;

/* CS AS ISO IN Endpoint */
static struct uac2_iso_endpoint_descriptor as_iso_in_desc =;

static struct usb_descriptor_header *fs_audio_desc[] =;

static struct usb_descriptor_header *hs_audio_desc[] =;

static struct usb_descriptor_header *ss_audio_desc[] =;

struct cntrl_cur_lay2 {};

struct cntrl_range_lay2 {} __packed;

struct cntrl_cur_lay3 {};

struct cntrl_subrange_lay3 {} __packed;

#define ranges_lay3_size(c)

#define DECLARE_UAC2_CNTRL_RANGES_LAY3(k, n)

DECLARE_UAC2_CNTRL_RANGES_LAY3(srates, UAC_MAX_RATES);

static int get_max_srate(const int *srates)
{}

static int get_max_bw_for_bint(const struct f_uac2_opts *uac2_opts,
	u8 bint, unsigned int factor, bool is_playback)
{}

static int set_ep_max_packet_size_bint(struct device *dev, const struct f_uac2_opts *uac2_opts,
	struct usb_endpoint_descriptor *ep_desc,
	enum usb_device_speed speed, bool is_playback)
{}

static struct uac2_feature_unit_descriptor *build_fu_desc(int chmask)
{}

/* Use macro to overcome line length limitation */
#define USBDHDR(p)

static void setup_headers(struct f_uac2_opts *opts,
			  struct usb_descriptor_header **headers,
			  enum usb_device_speed speed)
{}

static void setup_descriptor(struct f_uac2_opts *opts)
{}

static int afunc_validate_opts(struct g_audio *agdev, struct device *dev)
{}

static int
afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
{}

static void
afunc_notify_complete(struct usb_ep *_ep, struct usb_request *req)
{}

static int
afunc_notify(struct g_audio *agdev, int unit_id, int cs)
{}

static int
afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt)
{}

static int
afunc_get_alt(struct usb_function *fn, unsigned intf)
{}

static void
afunc_disable(struct usb_function *fn)
{}

static void
afunc_suspend(struct usb_function *fn)
{}

static int
in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
{}

static int
in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)
{}

static int
ac_rq_in(struct usb_function *fn, const struct usb_ctrlrequest *cr)
{}

static void uac2_cs_control_sam_freq(struct usb_ep *ep, struct usb_request *req)
{}

static void
out_rq_cur_complete(struct usb_ep *ep, struct usb_request *req)
{}

static int
out_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
{}

static int
setup_rq_inf(struct usb_function *fn, const struct usb_ctrlrequest *cr)
{}

static int
afunc_setup(struct usb_function *fn, const struct usb_ctrlrequest *cr)
{}

static inline struct f_uac2_opts *to_f_uac2_opts(struct config_item *item)
{}

static void f_uac2_attr_release(struct config_item *item)
{}

static struct configfs_item_operations f_uac2_item_ops =;

#define uac2_kstrtou8
#define uac2_kstrtou32
#define uac2_kstrtos16
#define uac2_kstrtobool(s, base, res)

static const char *u8_fmt =;
static const char *u32_fmt =;
static const char *s16_fmt =;
static const char *bool_fmt =;

#define UAC2_ATTRIBUTE(type, name)

#define UAC2_ATTRIBUTE_SYNC(name)

#define UAC2_RATE_ATTRIBUTE(name)

#define UAC2_ATTRIBUTE_STRING(name)

UAC2_ATTRIBUTE();
UAC2_RATE_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_RATE_ATTRIBUTE();
UAC2_ATTRIBUTE_SYNC();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();

UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();

UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();

UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();

UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();
UAC2_ATTRIBUTE_STRING();

UAC2_ATTRIBUTE();
UAC2_ATTRIBUTE();


static struct configfs_attribute *f_uac2_attrs[] =;

static const struct config_item_type f_uac2_func_type =;

static void afunc_free_inst(struct usb_function_instance *f)
{}

static struct usb_function_instance *afunc_alloc_inst(void)
{}

static void afunc_free(struct usb_function *f)
{}

static void afunc_unbind(struct usb_configuration *c, struct usb_function *f)
{}

static struct usb_function *afunc_alloc(struct usb_function_instance *fi)
{}

DECLARE_USB_FUNCTION_INIT(uac2, afunc_alloc_inst, afunc_alloc);
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();