// SPDX-License-Identifier: GPL-2.0-or-later /* * SQ905 subdriver * * Copyright (C) 2008, 2009 Adam Baker and Theodore Kilgore */ /* * History and Acknowledgments * * The original Linux driver for SQ905 based cameras was written by * Marcell Lengyel and further developed by many other contributors * and is available from http://sourceforge.net/projects/sqcam/ * * This driver takes advantage of the reverse engineering work done for * that driver and for libgphoto2 but shares no code with them. * * This driver has used as a base the finepix driver and other gspca * based drivers and may still contain code fragments taken from those * drivers. */ #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 SQ905_CMD_TIMEOUT … #define SQ905_DATA_TIMEOUT … /* Maximum transfer size to use. */ #define SQ905_MAX_TRANSFER … #define FRAME_HEADER_LEN … /* The known modes, or registers. These go in the "value" slot. */ /* 00 is "none" obviously */ #define SQ905_BULK_READ … #define SQ905_COMMAND … #define SQ905_PING … #define SQ905_READ_DONE … /* Any non-zero value in the bottom 2 bits of the 2nd byte of * the ID appears to indicate the camera can do 640*480. If the * LSB of that byte is set the image is just upside down, otherwise * it is rotated 180 degrees. */ #define SQ905_HIRES_MASK … #define SQ905_ORIENTATION_MASK … /* Some command codes. These go in the "index" slot. */ #define SQ905_ID … #define SQ905_CONFIG … #define SQ905_DATA … #define SQ905_CLEAR … #define SQ905_CAPTURE_LOW … #define SQ905_CAPTURE_MED … #define SQ905_CAPTURE_HIGH … /* note that the capture command also controls the output dimensions */ /* Structure to hold all of our device specific stuff */ struct sd { … }; static struct v4l2_pix_format sq905_mode[] = …; /* * Send a command to the camera. */ static int sq905_command(struct gspca_dev *gspca_dev, u16 index) { … } /* * Acknowledge the end of a frame - see warning on sq905_command. */ static int sq905_ack_frame(struct gspca_dev *gspca_dev) { … } /* * request and read a block of data - see warning on sq905_command. */ static int sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock) { … } /* * 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 sq905_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(…) …;