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

// SPDX-License-Identifier: GPL-2.0
/*
 * uvc_configfs.c
 *
 * Configfs support for the uvc function.
 *
 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * Author: Andrzej Pietrasiewicz <[email protected]>
 */

#include "uvc_configfs.h"

#include <linux/sort.h>
#include <linux/usb/uvc.h>
#include <linux/usb/video.h>

/* -----------------------------------------------------------------------------
 * Global Utility Structures and Macros
 */

#define UVC_ATTR(prefix, cname, aname)

#define UVC_ATTR_RO(prefix, cname, aname)

#define le8_to_cpu(x)
#define cpu_to_le8(x)

static int uvcg_config_compare_u32(const void *l, const void *r)
{}

static inline int __uvcg_count_item_entries(char *buf, void *priv, unsigned int size)
{}

static inline int __uvcg_fill_item_entries(char *buf, void *priv, unsigned int size)
{}

static int __uvcg_iter_item_entries(const char *page, size_t len,
				    int (*fun)(char *, void *, unsigned int),
				    void *priv, unsigned int size)
{}

struct uvcg_config_group_type {};

static void uvcg_config_item_release(struct config_item *item)
{}

static struct configfs_item_operations uvcg_config_item_ops =;

static int uvcg_config_create_group(struct config_group *parent,
				    const struct uvcg_config_group_type *type);

static int uvcg_config_create_children(struct config_group *group,
				const struct uvcg_config_group_type *type)
{}

static int uvcg_config_create_group(struct config_group *parent,
				    const struct uvcg_config_group_type *type)
{}

static void uvcg_config_remove_children(struct config_group *group)
{}

/* -----------------------------------------------------------------------------
 * control/header/<NAME>
 * control/header
 */

#define UVCG_CTRL_HDR_ATTR

UVCG_CTRL_HDR_ATTR;

UVCG_CTRL_HDR_ATTR;

#undef UVCG_CTRL_HDR_ATTR

static struct configfs_attribute *uvcg_control_header_attrs[] =;

static const struct config_item_type uvcg_control_header_type =;

static struct config_item *uvcg_control_header_make(struct config_group *group,
						    const char *name)
{}

static struct configfs_group_operations uvcg_control_header_grp_ops =;

static const struct uvcg_config_group_type uvcg_control_header_grp_type =;

/* -----------------------------------------------------------------------------
 * control/processing/default
 */

#define UVCG_DEFAULT_PROCESSING_ATTR

UVCG_DEFAULT_PROCESSING_ATTR;
UVCG_DEFAULT_PROCESSING_ATTR;
UVCG_DEFAULT_PROCESSING_ATTR;
UVCG_DEFAULT_PROCESSING_ATTR;

#undef UVCG_DEFAULT_PROCESSING_ATTR

static ssize_t uvcg_default_processing_bm_controls_store(
	struct config_item *item, const char *page, size_t len)
{}

static ssize_t uvcg_default_processing_bm_controls_show(
	struct config_item *item, char *page)
{}

UVC_ATTR();

static struct configfs_attribute *uvcg_default_processing_attrs[] =;

static const struct uvcg_config_group_type uvcg_default_processing_type =;

/* -----------------------------------------------------------------------------
 * control/processing
 */

static const struct uvcg_config_group_type uvcg_processing_grp_type =;

/* -----------------------------------------------------------------------------
 * control/terminal/camera/default
 */

#define UVCG_DEFAULT_CAMERA_ATTR

UVCG_DEFAULT_CAMERA_ATTR;
UVCG_DEFAULT_CAMERA_ATTR;
UVCG_DEFAULT_CAMERA_ATTR;
UVCG_DEFAULT_CAMERA_ATTR;
UVCG_DEFAULT_CAMERA_ATTR;
UVCG_DEFAULT_CAMERA_ATTR;
UVCG_DEFAULT_CAMERA_ATTR;

#undef UVCG_DEFAULT_CAMERA_ATTR

static ssize_t uvcg_default_camera_bm_controls_store(
	struct config_item *item, const char *page, size_t len)
{}

static ssize_t uvcg_default_camera_bm_controls_show(
	struct config_item *item, char *page)
{}

UVC_ATTR();

static struct configfs_attribute *uvcg_default_camera_attrs[] =;

static const struct uvcg_config_group_type uvcg_default_camera_type =;

/* -----------------------------------------------------------------------------
 * control/terminal/camera
 */

static const struct uvcg_config_group_type uvcg_camera_grp_type =;

/* -----------------------------------------------------------------------------
 * control/terminal/output/default
 */

#define UVCG_DEFAULT_OUTPUT_ATTR

UVCG_DEFAULT_OUTPUT_ATTR;
UVCG_DEFAULT_OUTPUT_ATTR;
UVCG_DEFAULT_OUTPUT_ATTR;
UVCG_DEFAULT_OUTPUT_ATTR;

#undef UVCG_DEFAULT_OUTPUT_ATTR

static ssize_t uvcg_default_output_b_source_id_show(struct config_item *item,
						    char *page)
{}

static ssize_t uvcg_default_output_b_source_id_store(struct config_item *item,
						     const char *page, size_t len)
{}
UVC_ATTR();

static struct configfs_attribute *uvcg_default_output_attrs[] =;

static const struct uvcg_config_group_type uvcg_default_output_type =;

/* -----------------------------------------------------------------------------
 * control/terminal/output
 */

static const struct uvcg_config_group_type uvcg_output_grp_type =;

/* -----------------------------------------------------------------------------
 * control/terminal
 */

static const struct uvcg_config_group_type uvcg_terminal_grp_type =;

/* -----------------------------------------------------------------------------
 * control/extensions
 */

#define UVCG_EXTENSION_ATTR(cname, aname, ro...)

UVCG_EXTENSION_ATTR();
UVCG_EXTENSION_ATTR();
UVCG_EXTENSION_ATTR();

static ssize_t uvcg_extension_b_num_controls_store(struct config_item *item,
						   const char *page, size_t len)
{}
UVCG_EXTENSION_ATTR();

/*
 * In addition to storing bNrInPins, this function needs to realloc the
 * memory for the baSourceID array and additionally expand bLength.
 */
static ssize_t uvcg_extension_b_nr_in_pins_store(struct config_item *item,
						 const char *page, size_t len)
{}
UVCG_EXTENSION_ATTR();

/*
 * In addition to storing bControlSize, this function needs to realloc the
 * memory for the bmControls array and additionally expand bLength.
 */
static ssize_t uvcg_extension_b_control_size_store(struct config_item *item,
						   const char *page, size_t len)
{}

UVCG_EXTENSION_ATTR();

static ssize_t uvcg_extension_guid_extension_code_show(struct config_item *item,
						       char *page)
{}

static ssize_t uvcg_extension_guid_extension_code_store(struct config_item *item,
							const char *page, size_t len)
{}

UVC_ATTR();

static ssize_t uvcg_extension_ba_source_id_show(struct config_item *item,
						char *page)
{}

static ssize_t uvcg_extension_ba_source_id_store(struct config_item *item,
						 const char *page, size_t len)
{}
UVC_ATTR();

static ssize_t uvcg_extension_bm_controls_show(struct config_item *item,
					       char *page)
{}

static ssize_t uvcg_extension_bm_controls_store(struct config_item *item,
						const char *page, size_t len)
{}

UVC_ATTR();

static struct configfs_attribute *uvcg_extension_attrs[] =;

static void uvcg_extension_release(struct config_item *item)
{}

static int uvcg_extension_allow_link(struct config_item *src, struct config_item *tgt)
{}

static void uvcg_extension_drop_link(struct config_item *src, struct config_item *tgt)
{}

static struct configfs_item_operations uvcg_extension_item_ops =;

static const struct config_item_type uvcg_extension_type =;

static void uvcg_extension_drop(struct config_group *group, struct config_item *item)
{}

static struct config_item *uvcg_extension_make(struct config_group *group, const char *name)
{}

static struct configfs_group_operations uvcg_extensions_grp_ops =;

static const struct uvcg_config_group_type uvcg_extensions_grp_type =;

/* -----------------------------------------------------------------------------
 * control/class/{fs|ss}
 */

struct uvcg_control_class_group {};

static inline struct uvc_descriptor_header
**uvcg_get_ctl_class_arr(struct config_item *i, struct f_uvc_opts *o)
{}

static int uvcg_control_class_allow_link(struct config_item *src,
					 struct config_item *target)
{}

static void uvcg_control_class_drop_link(struct config_item *src,
					struct config_item *target)
{}

static struct configfs_item_operations uvcg_control_class_item_ops =;

static const struct config_item_type uvcg_control_class_type =;

/* -----------------------------------------------------------------------------
 * control/class
 */

static int uvcg_control_class_create_children(struct config_group *parent)
{}

static const struct uvcg_config_group_type uvcg_control_class_grp_type =;

/* -----------------------------------------------------------------------------
 * control
 */

static ssize_t uvcg_default_control_b_interface_number_show(
	struct config_item *item, char *page)
{}

UVC_ATTR_RO();

static ssize_t uvcg_default_control_enable_interrupt_ep_show(
	struct config_item *item, char *page)
{}

static ssize_t uvcg_default_control_enable_interrupt_ep_store(
	struct config_item *item, const char *page, size_t len)
{}
UVC_ATTR();

static struct configfs_attribute *uvcg_default_control_attrs[] =;

static const struct uvcg_config_group_type uvcg_control_grp_type =;

/* -----------------------------------------------------------------------------
 * streaming/uncompressed
 * streaming/mjpeg
 */

static const char * const uvcg_format_names[] =;

static struct uvcg_color_matching *
uvcg_format_get_default_color_match(struct config_item *streaming)
{}

static int uvcg_format_allow_link(struct config_item *src, struct config_item *tgt)
{}

static void uvcg_format_drop_link(struct config_item *src, struct config_item *tgt)
{}

static struct configfs_item_operations uvcg_format_item_operations =;

static ssize_t uvcg_format_bma_controls_show(struct uvcg_format *f, char *page)
{}

static ssize_t uvcg_format_bma_controls_store(struct uvcg_format *ch,
					      const char *page, size_t len)
{}

/* -----------------------------------------------------------------------------
 * streaming/header/<NAME>
 * streaming/header
 */

static void uvcg_format_set_indices(struct config_group *fmt);

static int uvcg_streaming_header_allow_link(struct config_item *src,
					    struct config_item *target)
{}

static void uvcg_streaming_header_drop_link(struct config_item *src,
					   struct config_item *target)
{}

static struct configfs_item_operations uvcg_streaming_header_item_ops =;

#define UVCG_STREAMING_HEADER_ATTR

UVCG_STREAMING_HEADER_ATTR;
UVCG_STREAMING_HEADER_ATTR;
UVCG_STREAMING_HEADER_ATTR;
UVCG_STREAMING_HEADER_ATTR;
UVCG_STREAMING_HEADER_ATTR;

#undef UVCG_STREAMING_HEADER_ATTR

static struct configfs_attribute *uvcg_streaming_header_attrs[] =;

static const struct config_item_type uvcg_streaming_header_type =;

static struct config_item
*uvcg_streaming_header_make(struct config_group *group, const char *name)
{}

static struct configfs_group_operations uvcg_streaming_header_grp_ops =;

static const struct uvcg_config_group_type uvcg_streaming_header_grp_type =;

/* -----------------------------------------------------------------------------
 * streaming/<mode>/<format>/<NAME>
 */

#define UVCG_FRAME_ATTR

static ssize_t uvcg_frame_b_frame_index_show(struct config_item *item,
					     char *page)
{}

UVC_ATTR_RO();

UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, 8);
UVCG_FRAME_ATTR(w_width, wWidth, 16);
UVCG_FRAME_ATTR(w_height, wHeight, 16);
UVCG_FRAME_ATTR(dw_min_bit_rate, dwMinBitRate, 32);
UVCG_FRAME_ATTR(dw_max_bit_rate, dwMaxBitRate, 32);
UVCG_FRAME_ATTR(dw_max_video_frame_buffer_size, dwMaxVideoFrameBufferSize, 32);
UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval, 32);

#undef UVCG_FRAME_ATTR

static ssize_t uvcg_frame_dw_frame_interval_show(struct config_item *item,
						 char *page)
{}

static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item,
						  const char *page, size_t len)
{}

UVC_ATTR();

static struct configfs_attribute *uvcg_frame_attrs[] =;

static const struct config_item_type uvcg_frame_type =;

static struct config_item *uvcg_frame_make(struct config_group *group,
					   const char *name)
{}

static void uvcg_frame_drop(struct config_group *group, struct config_item *item)
{}

static void uvcg_format_set_indices(struct config_group *fmt)
{}

/* -----------------------------------------------------------------------------
 * streaming/uncompressed/<NAME>
 */

static struct configfs_group_operations uvcg_uncompressed_group_ops =;

static ssize_t uvcg_uncompressed_guid_format_show(struct config_item *item,
							char *page)
{}

static ssize_t uvcg_uncompressed_guid_format_store(struct config_item *item,
						   const char *page, size_t len)
{}

UVC_ATTR();

#define UVCG_UNCOMPRESSED_ATTR_RO

#define UVCG_UNCOMPRESSED_ATTR

UVCG_UNCOMPRESSED_ATTR_RO(b_format_index, bFormatIndex, 8);
UVCG_UNCOMPRESSED_ATTR(b_bits_per_pixel, bBitsPerPixel, 8);
UVCG_UNCOMPRESSED_ATTR(b_default_frame_index, bDefaultFrameIndex, 8);
UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_x, bAspectRatioX, 8);
UVCG_UNCOMPRESSED_ATTR_RO(b_aspect_ratio_y, bAspectRatioY, 8);
UVCG_UNCOMPRESSED_ATTR_RO(bm_interlace_flags, bmInterlaceFlags, 8);

#undef UVCG_UNCOMPRESSED_ATTR
#undef UVCG_UNCOMPRESSED_ATTR_RO

static inline ssize_t
uvcg_uncompressed_bma_controls_show(struct config_item *item, char *page)
{}

static inline ssize_t
uvcg_uncompressed_bma_controls_store(struct config_item *item,
				     const char *page, size_t len)
{}

UVC_ATTR();

static struct configfs_attribute *uvcg_uncompressed_attrs[] =;

static const struct config_item_type uvcg_uncompressed_type =;

static struct config_group *uvcg_uncompressed_make(struct config_group *group,
						   const char *name)
{}

static struct configfs_group_operations uvcg_uncompressed_grp_ops =;

static const struct uvcg_config_group_type uvcg_uncompressed_grp_type =;

/* -----------------------------------------------------------------------------
 * streaming/mjpeg/<NAME>
 */

static struct configfs_group_operations uvcg_mjpeg_group_ops =;

#define UVCG_MJPEG_ATTR_RO

#define UVCG_MJPEG_ATTR

UVCG_MJPEG_ATTR_RO;
UVCG_MJPEG_ATTR;
UVCG_MJPEG_ATTR_RO;
UVCG_MJPEG_ATTR_RO;
UVCG_MJPEG_ATTR_RO;
UVCG_MJPEG_ATTR_RO;

#undef UVCG_MJPEG_ATTR
#undef UVCG_MJPEG_ATTR_RO

static inline ssize_t
uvcg_mjpeg_bma_controls_show(struct config_item *item, char *page)
{}

static inline ssize_t
uvcg_mjpeg_bma_controls_store(struct config_item *item,
				     const char *page, size_t len)
{}

UVC_ATTR();

static struct configfs_attribute *uvcg_mjpeg_attrs[] =;

static const struct config_item_type uvcg_mjpeg_type =;

static struct config_group *uvcg_mjpeg_make(struct config_group *group,
						   const char *name)
{}

static struct configfs_group_operations uvcg_mjpeg_grp_ops =;

static const struct uvcg_config_group_type uvcg_mjpeg_grp_type =;

/* -----------------------------------------------------------------------------
 * streaming/color_matching/default
 */

#define UVCG_COLOR_MATCHING_ATTR

UVCG_COLOR_MATCHING_ATTR;
UVCG_COLOR_MATCHING_ATTR;
UVCG_COLOR_MATCHING_ATTR;

#undef UVCG_COLOR_MATCHING_ATTR

static struct configfs_attribute *uvcg_color_matching_attrs[] =;

static void uvcg_color_matching_release(struct config_item *item)
{}

static struct configfs_item_operations uvcg_color_matching_item_ops =;

static const struct config_item_type uvcg_color_matching_type =;

/* -----------------------------------------------------------------------------
 * streaming/color_matching
 */

static struct config_group *uvcg_color_matching_make(struct config_group *group,
						     const char *name)
{}

static struct configfs_group_operations uvcg_color_matching_grp_group_ops =;

static int uvcg_color_matching_create_children(struct config_group *parent)
{}

static const struct uvcg_config_group_type uvcg_color_matching_grp_type =;

/* -----------------------------------------------------------------------------
 * streaming/class/{fs|hs|ss}
 */

struct uvcg_streaming_class_group {};

static inline struct uvc_descriptor_header
***__uvcg_get_stream_class_arr(struct config_item *i, struct f_uvc_opts *o)
{}

enum uvcg_strm_type {};

/*
 * Iterate over a hierarchy of streaming descriptors' config items.
 * The items are created by the user with configfs.
 *
 * It "processes" the header pointed to by @priv1, then for each format
 * that follows the header "processes" the format itself and then for
 * each frame inside a format "processes" the frame.
 *
 * As a "processing" function the @fun is used.
 *
 * __uvcg_iter_strm_cls() is used in two context: first, to calculate
 * the amount of memory needed for an array of streaming descriptors
 * and second, to actually fill the array.
 *
 * @h: streaming header pointer
 * @priv2: an "inout" parameter (the caller might want to see the changes to it)
 * @priv3: an "inout" parameter (the caller might want to see the changes to it)
 * @fun: callback function for processing each level of the hierarchy
 */
static int __uvcg_iter_strm_cls(struct uvcg_streaming_header *h,
	void *priv2, void *priv3,
	int (*fun)(void *, void *, void *, int, enum uvcg_strm_type type))
{}

/*
 * Count how many bytes are needed for an array of streaming descriptors.
 *
 * @priv1: pointer to a header, format or frame
 * @priv2: inout parameter, accumulated size of the array
 * @priv3: inout parameter, accumulated number of the array elements
 * @n: unused, this function's prototype must match @fun in __uvcg_iter_strm_cls
 */
static int __uvcg_cnt_strm(void *priv1, void *priv2, void *priv3, int n,
			   enum uvcg_strm_type type)
{}

/*
 * Fill an array of streaming descriptors.
 *
 * @priv1: pointer to a header, format or frame
 * @priv2: inout parameter, pointer into a block of memory
 * @priv3: inout parameter, pointer to a 2-dimensional array
 */
static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n,
			    enum uvcg_strm_type type)
{}

static int uvcg_streaming_class_allow_link(struct config_item *src,
					   struct config_item *target)
{}

static void uvcg_streaming_class_drop_link(struct config_item *src,
					  struct config_item *target)
{}

static struct configfs_item_operations uvcg_streaming_class_item_ops =;

static const struct config_item_type uvcg_streaming_class_type =;

/* -----------------------------------------------------------------------------
 * streaming/class
 */

static int uvcg_streaming_class_create_children(struct config_group *parent)
{}

static const struct uvcg_config_group_type uvcg_streaming_class_grp_type =;

/* -----------------------------------------------------------------------------
 * streaming
 */

static ssize_t uvcg_default_streaming_b_interface_number_show(
	struct config_item *item, char *page)
{}

UVC_ATTR_RO();

static struct configfs_attribute *uvcg_default_streaming_attrs[] =;

static const struct uvcg_config_group_type uvcg_streaming_grp_type =;

/* -----------------------------------------------------------------------------
 * UVC function
 */

static void uvc_func_item_release(struct config_item *item)
{}

static int uvc_func_allow_link(struct config_item *src, struct config_item *tgt)
{}

static void uvc_func_drop_link(struct config_item *src, struct config_item *tgt)
{}

static struct configfs_item_operations uvc_func_item_ops =;

#define UVCG_OPTS_ATTR

UVCG_OPTS_ATTR;
UVCG_OPTS_ATTR;
UVCG_OPTS_ATTR;

#undef UVCG_OPTS_ATTR

#define UVCG_OPTS_STRING_ATTR

UVCG_OPTS_STRING_ATTR;

#undef UVCG_OPTS_STRING_ATTR

static struct configfs_attribute *uvc_attrs[] =;

static const struct uvcg_config_group_type uvc_func_type =;

int uvcg_attach_configfs(struct f_uvc_opts *opts)
{}