// SPDX-License-Identifier: GPL-2.0-or-later /* * SQ905C subdriver * * Copyright (C) 2009 Theodore Kilgore */ /* * * This driver uses work done in * libgphoto2/camlibs/digigr8, Copyright (C) Theodore Kilgore. * * This driver has also used as a base the sq905c driver * and may contain code fragments from it. */ #define pr_fmt(fmt) … #define MODULE_NAME … #include <linux/workqueue.h> #include <linux/slab.h> #include "gspca.h" MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; /* Default timeouts, in ms */ #define SQ905C_CMD_TIMEOUT … #define SQ905C_DATA_TIMEOUT … /* Maximum transfer size to use. */ #define SQ905C_MAX_TRANSFER … #define FRAME_HEADER_LEN … /* Commands. These go in the "value" slot. */ #define SQ905C_CLEAR … #define SQ905C_GET_ID … #define SQ905C_CAPTURE_LOW … #define SQ905C_CAPTURE_MED … #define SQ905C_CAPTURE_HI … /* For capture, this must go in the "index" slot. */ #define SQ905C_CAPTURE_INDEX … /* Structure to hold all of our device specific stuff */ struct sd { … }; /* * Most of these cameras will do 640x480 and 320x240. 160x120 works * in theory but gives very poor output. Therefore, not supported. * The 0x2770:0x9050 cameras have max resolution of 320x240. */ static struct v4l2_pix_format sq905c_mode[] = …; /* Send a command to the camera. */ static int sq905c_command(struct gspca_dev *gspca_dev, u16 command, u16 index) { … } static int sq905c_read(struct gspca_dev *gspca_dev, u16 command, u16 index, int size) { … } /* * This function is called as a workqueue function and runs whenever the camera * is streaming data. Because it is a workqueue function it is allowed to sleep * so we can use synchronous USB calls. To avoid possible collisions with other * threads attempting to use gspca_dev->usb_buf we take the usb_lock when * performing USB operations using it. In practice we don't really need this * as the camera doesn't provide any controls. */ static void sq905c_dostream(struct work_struct *work) { … } /* This function is called at probe time just before sd_init */ static int sd_config(struct gspca_dev *gspca_dev, const struct usb_device_id *id) { … } /* called on streamoff with alt==0 and on disconnect */ /* the usb_lock is held at entry - restore on exit */ static void sd_stop0(struct gspca_dev *gspca_dev) { … } /* this function is called at probe and resume time */ static int sd_init(struct gspca_dev *gspca_dev) { … } /* Set up for getting frames. */ static int sd_start(struct gspca_dev *gspca_dev) { … } /* Table of supported USB devices */ static const struct usb_device_id device_table[] = …; MODULE_DEVICE_TABLE(usb, device_table); /* sub-driver description */ static const struct sd_desc sd_desc = …; /* -- device connect -- */ static int sd_probe(struct usb_interface *intf, const struct usb_device_id *id) { … } static struct usb_driver sd_driver = …; module_usb_driver(…) …;