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

// SPDX-License-Identifier: GPL-2.0+
/*
 * f_uac1.c -- USB Audio Class 1.0 Function (using u_audio API)
 *
 * Copyright (C) 2016 Ruslan Bilovol <[email protected]>
 * Copyright (C) 2021 Julian Scheel <[email protected]>
 *
 * This driver doesn't expect any real Audio codec to be present
 * on the device - the audio streams are simply sinked to and
 * sourced from a virtual ALSA sound card created.
 *
 * This file is based on f_uac1.c which is
 *   Copyright (C) 2008 Bryan Wu <[email protected]>
 *   Copyright (C) 2008 Analog Devices, Inc
 */

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

#include "u_audio.h"
#include "u_uac1.h"

/* UAC1 spec: 3.7.2.3 Audio Channel Cluster Format */
#define UAC1_CHANNEL_MASK

#define USB_OUT_FU_ID
#define USB_IN_FU_ID

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

struct f_uac1 {};

static inline struct f_uac1 *func_to_uac1(struct usb_function *f)
{}

static inline struct f_uac1_opts *g_audio_to_uac1_opts(struct g_audio *audio)
{}

/*
 * DESCRIPTORS ... most are static, but strings and full
 * configuration descriptors are built on demand.
 */

/*
 * We have three interfaces - one AudioControl and two AudioStreaming
 *
 * The driver implements a simple UAC_1 topology.
 * USB-OUT -> IT_1 -> OT_2 -> ALSA_Capture
 * ALSA_Playback -> IT_3 -> OT_4 -> USB-IN
 */

/* B.3.1  Standard AC Interface Descriptor */
static struct usb_interface_descriptor ac_interface_desc =;

/* B.3.2  Class-Specific AC Interface Descriptor */
static struct uac1_ac_header_descriptor *ac_header_desc;

static struct uac_input_terminal_descriptor usb_out_it_desc =;

static struct uac1_output_terminal_descriptor io_out_ot_desc =;

static struct uac_input_terminal_descriptor io_in_it_desc =;

static struct uac1_output_terminal_descriptor usb_in_ot_desc =;

static struct uac_feature_unit_descriptor *in_feature_unit_desc;
static struct uac_feature_unit_descriptor *out_feature_unit_desc;

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

/* B.4.1  Standard AS Interface Descriptor */
static struct usb_interface_descriptor as_out_interface_alt_0_desc =;

static struct usb_interface_descriptor as_out_interface_alt_1_desc =;

static struct usb_interface_descriptor as_in_interface_alt_0_desc =;

static struct usb_interface_descriptor as_in_interface_alt_1_desc =;

/* B.4.2  Class-Specific AS Interface Descriptor */
static struct uac1_as_header_descriptor as_out_header_desc =;

static struct uac1_as_header_descriptor as_in_header_desc =;

DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC();
#define uac_format_type_i_discrete_descriptor

static struct uac_format_type_i_discrete_descriptor as_out_type_i_desc =;

/* Standard ISO OUT Endpoint Descriptor */
static struct usb_endpoint_descriptor as_out_ep_desc  =;

/* Class-specific AS ISO OUT Endpoint Descriptor */
static struct uac_iso_endpoint_descriptor as_iso_out_desc =;

static struct uac_format_type_i_discrete_descriptor as_in_type_i_desc =;

/* Standard ISO OUT Endpoint Descriptor */
static struct usb_endpoint_descriptor as_in_ep_desc  =;

/* Class-specific AS ISO OUT Endpoint Descriptor */
static struct uac_iso_endpoint_descriptor as_iso_in_desc =;

static struct usb_descriptor_header *f_audio_desc[] =;

/* Standard ISO OUT Endpoint Descriptor */
static struct usb_endpoint_descriptor ss_as_out_ep_desc  =;

static struct usb_ss_ep_comp_descriptor ss_as_out_ep_desc_comp =;

/* Standard ISO OUT Endpoint Descriptor */
static struct usb_endpoint_descriptor ss_as_in_ep_desc  =;

static struct usb_ss_ep_comp_descriptor ss_as_in_ep_desc_comp =;

static struct usb_descriptor_header *f_audio_ss_desc[] =;

enum {};

static struct usb_string strings_uac1[NUM_STR_DESCRIPTORS + 1] =;

static struct usb_gadget_strings str_uac1 =;

static struct usb_gadget_strings *uac1_strings[] =;

/*
 * This function is an ALSA sound card following USB Audio Class Spec 1.0.
 */

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

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

static int audio_notify(struct g_audio *audio, int unit_id, int cs)
{}

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

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

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

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

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 ac_rq_in(struct usb_function *f,
		const struct usb_ctrlrequest *ctrl)
{}

static int audio_set_endpoint_req(struct usb_function *f,
		const struct usb_ctrlrequest *ctrl)
{}

static int audio_get_endpoint_req(struct usb_function *f,
		const struct usb_ctrlrequest *ctrl)
{}

static int
f_audio_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
{}

static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
{}

static int f_audio_get_alt(struct usb_function *f, unsigned intf)
{}


static void f_audio_disable(struct usb_function *f)
{}

static void
f_audio_suspend(struct usb_function *f)
{}

/*-------------------------------------------------------------------------*/
static struct uac_feature_unit_descriptor *build_fu_desc(int chmask)
{}

/* B.3.2  Class-Specific AC Interface Descriptor */
static struct
uac1_ac_header_descriptor *build_ac_header_desc(struct f_uac1_opts *opts)
{}

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

static void setup_descriptor(struct f_uac1_opts *opts)
{}

static int f_audio_validate_opts(struct g_audio *audio, struct device *dev)
{}

/* audio function driver setup/binding */
static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
{}

/*-------------------------------------------------------------------------*/

static inline struct f_uac1_opts *to_f_uac1_opts(struct config_item *item)
{}

static void f_uac1_attr_release(struct config_item *item)
{}

static struct configfs_item_operations f_uac1_item_ops =;

#define uac1_kstrtou32
#define uac1_kstrtos16
#define uac1_kstrtobool(s, base, res)

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

#define UAC1_ATTRIBUTE(type, name)

#define UAC1_RATE_ATTRIBUTE(name)

#define UAC1_ATTRIBUTE_STRING(name)

UAC1_ATTRIBUTE();
UAC1_RATE_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_RATE_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();

UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();

UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();
UAC1_ATTRIBUTE();

UAC1_ATTRIBUTE_STRING();

UAC1_ATTRIBUTE_STRING();
UAC1_ATTRIBUTE_STRING();
UAC1_ATTRIBUTE_STRING();
UAC1_ATTRIBUTE_STRING();

UAC1_ATTRIBUTE_STRING();
UAC1_ATTRIBUTE_STRING();
UAC1_ATTRIBUTE_STRING();
UAC1_ATTRIBUTE_STRING();

static struct configfs_attribute *f_uac1_attrs[] =;

static const struct config_item_type f_uac1_func_type =;

static void f_audio_free_inst(struct usb_function_instance *f)
{}

static struct usb_function_instance *f_audio_alloc_inst(void)
{}

static void f_audio_free(struct usb_function *f)
{}

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

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

DECLARE_USB_FUNCTION_INIT(uac1, f_audio_alloc_inst, f_audio_alloc);
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();