linux/drivers/media/usb/uvc/uvc_driver.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *      uvc_driver.c  --  USB Video Class driver
 *
 *      Copyright (C) 2005-2010
 *          Laurent Pinchart ([email protected])
 */

#include <linux/atomic.h>
#include <linux/bits.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/usb/quirks.h>
#include <linux/usb/uvc.h>
#include <linux/videodev2.h>
#include <linux/vmalloc.h>
#include <linux/wait.h>
#include <asm/unaligned.h>

#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>

#include "uvcvideo.h"

#define DRIVER_AUTHOR
#define DRIVER_DESC

unsigned int uvc_clock_param =;
unsigned int uvc_hw_timestamps_param;
unsigned int uvc_no_drop_param;
static unsigned int uvc_quirks_param =;
unsigned int uvc_dbg_param;
unsigned int uvc_timeout_param =;

/* ------------------------------------------------------------------------
 * Utility functions
 */

struct usb_host_endpoint *uvc_find_endpoint(struct usb_host_interface *alts,
		u8 epaddr)
{}

static enum v4l2_colorspace uvc_colorspace(const u8 primaries)
{}

static enum v4l2_xfer_func uvc_xfer_func(const u8 transfer_characteristics)
{}

static enum v4l2_ycbcr_encoding uvc_ycbcr_enc(const u8 matrix_coefficients)
{}

/* ------------------------------------------------------------------------
 * Terminal and unit management
 */

struct uvc_entity *uvc_entity_by_id(struct uvc_device *dev, int id)
{}

static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
	int id, struct uvc_entity *entity)
{}

static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id)
{}

/* ------------------------------------------------------------------------
 * Streaming Object Management
 */

static void uvc_stream_delete(struct uvc_streaming *stream)
{}

static struct uvc_streaming *uvc_stream_new(struct uvc_device *dev,
					    struct usb_interface *intf)
{}

/* ------------------------------------------------------------------------
 * Descriptors parsing
 */

static int uvc_parse_format(struct uvc_device *dev,
	struct uvc_streaming *streaming, struct uvc_format *format,
	struct uvc_frame *frames, u32 **intervals, const unsigned char *buffer,
	int buflen)
{}

static int uvc_parse_streaming(struct uvc_device *dev,
	struct usb_interface *intf)
{}

static const u8 uvc_camera_guid[16] =;
static const u8 uvc_gpio_guid[16] =;
static const u8 uvc_media_transport_input_guid[16] =;
static const u8 uvc_processing_guid[16] =;

static struct uvc_entity *uvc_alloc_entity(u16 type, u16 id,
		unsigned int num_pads, unsigned int extra_size)
{}

static void uvc_entity_set_name(struct uvc_device *dev, struct uvc_entity *entity,
				const char *type_name, u8 string_id)
{}

/* Parse vendor-specific extensions. */
static int uvc_parse_vendor_control(struct uvc_device *dev,
	const unsigned char *buffer, int buflen)
{}

static int uvc_parse_standard_control(struct uvc_device *dev,
	const unsigned char *buffer, int buflen)
{}

static int uvc_parse_control(struct uvc_device *dev)
{}

/* -----------------------------------------------------------------------------
 * Privacy GPIO
 */

static void uvc_gpio_event(struct uvc_device *dev)
{}

static int uvc_gpio_get_cur(struct uvc_device *dev, struct uvc_entity *entity,
			    u8 cs, void *data, u16 size)
{}

static int uvc_gpio_get_info(struct uvc_device *dev, struct uvc_entity *entity,
			     u8 cs, u8 *caps)
{}

static irqreturn_t uvc_gpio_irq(int irq, void *data)
{}

static int uvc_gpio_parse(struct uvc_device *dev)
{}

static int uvc_gpio_init_irq(struct uvc_device *dev)
{}

/* ------------------------------------------------------------------------
 * UVC device scan
 */

/*
 * Scan the UVC descriptors to locate a chain starting at an Output Terminal
 * and containing the following units:
 *
 * - one or more Output Terminals (USB Streaming or Display)
 * - zero or one Processing Unit
 * - zero, one or more single-input Selector Units
 * - zero or one multiple-input Selector Units, provided all inputs are
 *   connected to input terminals
 * - zero, one or mode single-input Extension Units
 * - one or more Input Terminals (Camera, External or USB Streaming)
 *
 * The terminal and units must match on of the following structures:
 *
 * ITT_*(0) -> +---------+    +---------+    +---------+ -> TT_STREAMING(0)
 * ...         | SU{0,1} | -> | PU{0,1} | -> | XU{0,n} |    ...
 * ITT_*(n) -> +---------+    +---------+    +---------+ -> TT_STREAMING(n)
 *
 *                 +---------+    +---------+ -> OTT_*(0)
 * TT_STREAMING -> | PU{0,1} | -> | XU{0,n} |    ...
 *                 +---------+    +---------+ -> OTT_*(n)
 *
 * The Processing Unit and Extension Units can be in any order. Additional
 * Extension Units connected to the main chain as single-unit branches are
 * also supported. Single-input Selector Units are ignored.
 */
static int uvc_scan_chain_entity(struct uvc_video_chain *chain,
	struct uvc_entity *entity)
{}

static int uvc_scan_chain_forward(struct uvc_video_chain *chain,
	struct uvc_entity *entity, struct uvc_entity *prev)
{}

static int uvc_scan_chain_backward(struct uvc_video_chain *chain,
	struct uvc_entity **_entity)
{}

static int uvc_scan_chain(struct uvc_video_chain *chain,
			  struct uvc_entity *term)
{}

static unsigned int uvc_print_terms(struct list_head *terms, u16 dir,
		char *buffer)
{}

static const char *uvc_print_chain(struct uvc_video_chain *chain)
{}

static struct uvc_video_chain *uvc_alloc_chain(struct uvc_device *dev)
{}

/*
 * Fallback heuristic for devices that don't connect units and terminals in a
 * valid chain.
 *
 * Some devices have invalid baSourceID references, causing uvc_scan_chain()
 * to fail, but if we just take the entities we can find and put them together
 * in the most sensible chain we can think of, turns out they do work anyway.
 * Note: This heuristic assumes there is a single chain.
 *
 * At the time of writing, devices known to have such a broken chain are
 *  - Acer Integrated Camera (5986:055a)
 *  - Realtek rtl157a7 (0bda:57a7)
 */
static int uvc_scan_fallback(struct uvc_device *dev)
{}

/*
 * Scan the device for video chains and register video devices.
 *
 * Chains are scanned starting at their output terminals and walked backwards.
 */
static int uvc_scan_device(struct uvc_device *dev)
{}

/* ------------------------------------------------------------------------
 * Video device registration and unregistration
 */

/*
 * Delete the UVC device.
 *
 * Called by the kernel when the last reference to the uvc_device structure
 * is released.
 *
 * As this function is called after or during disconnect(), all URBs have
 * already been cancelled by the USB core. There is no need to kill the
 * interrupt URB manually.
 */
static void uvc_delete(struct kref *kref)
{}

static void uvc_release(struct video_device *vdev)
{}

/*
 * Unregister the video devices.
 */
static void uvc_unregister_video(struct uvc_device *dev)
{}

int uvc_register_video_device(struct uvc_device *dev,
			      struct uvc_streaming *stream,
			      struct video_device *vdev,
			      struct uvc_video_queue *queue,
			      enum v4l2_buf_type type,
			      const struct v4l2_file_operations *fops,
			      const struct v4l2_ioctl_ops *ioctl_ops)
{}

static int uvc_register_video(struct uvc_device *dev,
		struct uvc_streaming *stream)
{}

/*
 * Register all video devices in all chains.
 */
static int uvc_register_terms(struct uvc_device *dev,
	struct uvc_video_chain *chain)
{}

static int uvc_register_chains(struct uvc_device *dev)
{}

/* ------------------------------------------------------------------------
 * USB probe, disconnect, suspend and resume
 */

static const struct uvc_device_info uvc_quirk_none =;

static int uvc_probe(struct usb_interface *intf,
		     const struct usb_device_id *id)
{}

static void uvc_disconnect(struct usb_interface *intf)
{}

static int uvc_suspend(struct usb_interface *intf, pm_message_t message)
{}

static int __uvc_resume(struct usb_interface *intf, int reset)
{}

static int uvc_resume(struct usb_interface *intf)
{}

static int uvc_reset_resume(struct usb_interface *intf)
{}

/* ------------------------------------------------------------------------
 * Module parameters
 */

static int uvc_clock_param_get(char *buffer, const struct kernel_param *kp)
{}

static int uvc_clock_param_set(const char *val, const struct kernel_param *kp)
{}

module_param_call();
MODULE_PARM_DESC();
module_param_named(hwtimestamps, uvc_hw_timestamps_param, uint, 0644);
MODULE_PARM_DESC();
module_param_named(nodrop, uvc_no_drop_param, uint, 0644);
MODULE_PARM_DESC();
module_param_named(quirks, uvc_quirks_param, uint, 0644);
MODULE_PARM_DESC();
module_param_named(trace, uvc_dbg_param, uint, 0644);
MODULE_PARM_DESC();
module_param_named(timeout, uvc_timeout_param, uint, 0644);
MODULE_PARM_DESC();

/* ------------------------------------------------------------------------
 * Driver initialization and cleanup
 */

static const struct uvc_device_info uvc_quirk_probe_minmax =;

static const struct uvc_device_info uvc_quirk_fix_bandwidth =;

static const struct uvc_device_info uvc_quirk_probe_def =;

static const struct uvc_device_info uvc_quirk_stream_no_fid =;

static const struct uvc_device_info uvc_quirk_force_y8 =;

#define UVC_INFO_QUIRK(q)
#define UVC_INFO_META(m)

/*
 * The Logitech cameras listed below have their interface class set to
 * VENDOR_SPEC because they don't announce themselves as UVC devices, even
 * though they are compliant.
 */
static const struct usb_device_id uvc_ids[] =;

MODULE_DEVICE_TABLE(usb, uvc_ids);

struct uvc_driver uvc_driver =;

static int __init uvc_init(void)
{}

static void __exit uvc_cleanup(void)
{}

module_init();
module_exit(uvc_cleanup);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_VERSION();