linux/drivers/media/usb/gspca/cpia1.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * cpia CPiA (1) gspca driver
 *
 * Copyright (C) 2010-2011 Hans de Goede <[email protected]>
 *
 * This module is adapted from the in kernel v4l1 cpia driver which is :
 *
 * (C) Copyright 1999-2000 Peter Pregler
 * (C) Copyright 1999-2000 Scott J. Bertin
 * (C) Copyright 1999-2000 Johannes Erdfelt <[email protected]>
 * (C) Copyright 2000 STMicroelectronics
 */

#define pr_fmt(fmt)

#define MODULE_NAME

#include <linux/input.h>
#include <linux/sched/signal.h>
#include <linux/bitops.h>

#include "gspca.h"

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

/* constant value's */
#define MAGIC_0
#define MAGIC_1
#define DATA_IN
#define DATA_OUT
#define VIDEOSIZE_QCIF
#define VIDEOSIZE_CIF
#define SUBSAMPLE_420
#define SUBSAMPLE_422
#define YUVORDER_YUYV
#define YUVORDER_UYVY
#define NOT_COMPRESSED
#define COMPRESSED
#define NO_DECIMATION
#define DECIMATION_ENAB
#define EOI
#define EOL
#define FRAME_HEADER_SIZE

/* Image grab modes */
#define CPIA_GRAB_SINGLE
#define CPIA_GRAB_CONTINEOUS

/* Compression parameters */
#define CPIA_COMPRESSION_NONE
#define CPIA_COMPRESSION_AUTO
#define CPIA_COMPRESSION_MANUAL
#define CPIA_COMPRESSION_TARGET_QUALITY
#define CPIA_COMPRESSION_TARGET_FRAMERATE

/* Return offsets for GetCameraState */
#define SYSTEMSTATE
#define GRABSTATE
#define STREAMSTATE
#define FATALERROR
#define CMDERROR
#define DEBUGFLAGS
#define VPSTATUS
#define ERRORCODE

/* SystemState */
#define UNINITIALISED_STATE
#define PASS_THROUGH_STATE
#define LO_POWER_STATE
#define HI_POWER_STATE
#define WARM_BOOT_STATE

/* GrabState */
#define GRAB_IDLE
#define GRAB_ACTIVE
#define GRAB_DONE

/* StreamState */
#define STREAM_NOT_READY
#define STREAM_READY
#define STREAM_OPEN
#define STREAM_PAUSED
#define STREAM_FINISHED

/* Fatal Error, CmdError, and DebugFlags */
#define CPIA_FLAG
#define SYSTEM_FLAG
#define INT_CTRL_FLAG
#define PROCESS_FLAG
#define COM_FLAG
#define VP_CTRL_FLAG
#define CAPTURE_FLAG
#define DEBUG_FLAG

/* VPStatus */
#define VP_STATE_OK

#define VP_STATE_FAILED_VIDEOINIT
#define VP_STATE_FAILED_AECACBINIT
#define VP_STATE_AEC_MAX
#define VP_STATE_ACB_BMAX

#define VP_STATE_ACB_RMIN
#define VP_STATE_ACB_GMIN
#define VP_STATE_ACB_RMAX
#define VP_STATE_ACB_GMAX

/* default (minimum) compensation values */
#define COMP_RED
#define COMP_GREEN1
#define COMP_GREEN2
#define COMP_BLUE

/* exposure status */
#define EXPOSURE_VERY_LIGHT
#define EXPOSURE_LIGHT
#define EXPOSURE_NORMAL
#define EXPOSURE_DARK
#define EXPOSURE_VERY_DARK

#define CPIA_MODULE_CPIA
#define CPIA_MODULE_SYSTEM
#define CPIA_MODULE_VP_CTRL
#define CPIA_MODULE_CAPTURE
#define CPIA_MODULE_DEBUG

#define INPUT
#define OUTPUT

#define CPIA_COMMAND_GetCPIAVersion
#define CPIA_COMMAND_GetPnPID
#define CPIA_COMMAND_GetCameraStatus
#define CPIA_COMMAND_GotoHiPower
#define CPIA_COMMAND_GotoLoPower
#define CPIA_COMMAND_GotoSuspend
#define CPIA_COMMAND_GotoPassThrough
#define CPIA_COMMAND_ModifyCameraStatus

#define CPIA_COMMAND_ReadVCRegs
#define CPIA_COMMAND_WriteVCReg
#define CPIA_COMMAND_ReadMCPorts
#define CPIA_COMMAND_WriteMCPort
#define CPIA_COMMAND_SetBaudRate
#define CPIA_COMMAND_SetECPTiming
#define CPIA_COMMAND_ReadIDATA
#define CPIA_COMMAND_WriteIDATA
#define CPIA_COMMAND_GenericCall
#define CPIA_COMMAND_I2CStart
#define CPIA_COMMAND_I2CStop
#define CPIA_COMMAND_I2CWrite
#define CPIA_COMMAND_I2CRead

#define CPIA_COMMAND_GetVPVersion
#define CPIA_COMMAND_ResetFrameCounter
#define CPIA_COMMAND_SetColourParams
#define CPIA_COMMAND_SetExposure
#define CPIA_COMMAND_SetColourBalance
#define CPIA_COMMAND_SetSensorFPS
#define CPIA_COMMAND_SetVPDefaults
#define CPIA_COMMAND_SetApcor
#define CPIA_COMMAND_SetFlickerCtrl
#define CPIA_COMMAND_SetVLOffset
#define CPIA_COMMAND_GetColourParams
#define CPIA_COMMAND_GetColourBalance
#define CPIA_COMMAND_GetExposure
#define CPIA_COMMAND_SetSensorMatrix
#define CPIA_COMMAND_ColourBars
#define CPIA_COMMAND_ReadVPRegs
#define CPIA_COMMAND_WriteVPReg

#define CPIA_COMMAND_GrabFrame
#define CPIA_COMMAND_UploadFrame
#define CPIA_COMMAND_SetGrabMode
#define CPIA_COMMAND_InitStreamCap
#define CPIA_COMMAND_FiniStreamCap
#define CPIA_COMMAND_StartStreamCap
#define CPIA_COMMAND_EndStreamCap
#define CPIA_COMMAND_SetFormat
#define CPIA_COMMAND_SetROI
#define CPIA_COMMAND_SetCompression
#define CPIA_COMMAND_SetCompressionTarget
#define CPIA_COMMAND_SetYUVThresh
#define CPIA_COMMAND_SetCompressionParams
#define CPIA_COMMAND_DiscardFrame
#define CPIA_COMMAND_GrabReset

#define CPIA_COMMAND_OutputRS232
#define CPIA_COMMAND_AbortProcess
#define CPIA_COMMAND_SetDramPage
#define CPIA_COMMAND_StartDramUpload
#define CPIA_COMMAND_StartDummyDtream
#define CPIA_COMMAND_AbortStream
#define CPIA_COMMAND_DownloadDRAM
#define CPIA_COMMAND_Null

#define ROUND_UP_EXP_FOR_FLICKER

/* Constants for automatic frame rate adjustment */
#define MAX_EXP
#define MAX_EXP_102
#define LOW_EXP
#define VERY_LOW_EXP
#define TC
#define EXP_ACC_DARK
#define EXP_ACC_LIGHT
#define HIGH_COMP_102
#define MAX_COMP
#define DARK_TIME
#define LIGHT_TIME

#define FIRMWARE_VERSION(x, y)

#define CPIA1_CID_COMP_TARGET
#define BRIGHTNESS_DEF
#define CONTRAST_DEF
#define SATURATION_DEF
#define FREQ_DEF
#define ILLUMINATORS_1_DEF
#define ILLUMINATORS_2_DEF
#define COMP_TARGET_DEF

/* Developer's Guide Table 5 p 3-34
 * indexed by [mains][sensorFps.baserate][sensorFps.divisor]*/
static u8 flicker_jumps[2][2][4] =;

struct cam_params {};

/* specific webcam descriptor */
struct sd {};

static const struct v4l2_pix_format mode[] =;

/**********************************************************************
 *
 * General functions
 *
 **********************************************************************/

static int cpia_usb_transferCmd(struct gspca_dev *gspca_dev, u8 *command)
{}

/* send an arbitrary command to the camera */
static int do_command(struct gspca_dev *gspca_dev, u16 command,
		      u8 a, u8 b, u8 c, u8 d)
{}

/* send a command to the camera with an additional data transaction */
static int do_command_extended(struct gspca_dev *gspca_dev, u16 command,
			       u8 a, u8 b, u8 c, u8 d,
			       u8 e, u8 f, u8 g, u8 h,
			       u8 i, u8 j, u8 k, u8 l)
{}

/*  find_over_exposure
 *  Finds a suitable value of OverExposure for use with SetFlickerCtrl
 *  Some calculation is required because this value changes with the brightness
 *  set with SetColourParameters
 *
 *  Parameters: Brightness - last brightness value set with SetColourParameters
 *
 *  Returns: OverExposure value to use with SetFlickerCtrl
 */
#define FLICKER_MAX_EXPOSURE
#define FLICKER_ALLOWABLE_OVER_EXPOSURE
#define FLICKER_BRIGHTNESS_CONSTANT
static int find_over_exposure(int brightness)
{}
#undef FLICKER_MAX_EXPOSURE
#undef FLICKER_ALLOWABLE_OVER_EXPOSURE
#undef FLICKER_BRIGHTNESS_CONSTANT

/* initialise cam_data structure  */
static void reset_camera_params(struct gspca_dev *gspca_dev)
{}

static void printstatus(struct gspca_dev *gspca_dev, struct cam_params *params)
{}

static int goto_low_power(struct gspca_dev *gspca_dev)
{}

static int goto_high_power(struct gspca_dev *gspca_dev)
{}

static int get_version_information(struct gspca_dev *gspca_dev)
{}

static int save_camera_state(struct gspca_dev *gspca_dev)
{}

static int command_setformat(struct gspca_dev *gspca_dev)
{}

static int command_setcolourparams(struct gspca_dev *gspca_dev)
{}

static int command_setapcor(struct gspca_dev *gspca_dev)
{}

static int command_setvloffset(struct gspca_dev *gspca_dev)
{}

static int command_setexposure(struct gspca_dev *gspca_dev)
{}

static int command_setcolourbalance(struct gspca_dev *gspca_dev)
{}

static int command_setcompressiontarget(struct gspca_dev *gspca_dev)
{}

static int command_setyuvtresh(struct gspca_dev *gspca_dev)
{}

static int command_setcompressionparams(struct gspca_dev *gspca_dev)
{}

static int command_setcompression(struct gspca_dev *gspca_dev)
{}

static int command_setsensorfps(struct gspca_dev *gspca_dev)
{}

static int command_setflickerctrl(struct gspca_dev *gspca_dev)
{}

static int command_setecptiming(struct gspca_dev *gspca_dev)
{}

static int command_pause(struct gspca_dev *gspca_dev)
{}

static int command_resume(struct gspca_dev *gspca_dev)
{}

static int command_setlights(struct gspca_dev *gspca_dev)
{}

static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply)
{}

/* monitor the exposure and adjust the sensor frame rate if needed */
static void monitor_exposure(struct gspca_dev *gspca_dev)
{}

/*-----------------------------------------------------------------*/
/* if flicker is switched off, this function switches it back on.It checks,
   however, that conditions are suitable before restarting it.
   This should only be called for firmware version 1.2.

   It also adjust the colour balance when an exposure step is detected - as
   long as flicker is running
*/
static void restart_flicker(struct gspca_dev *gspca_dev)
{}

/* this function is called at probe time */
static int sd_config(struct gspca_dev *gspca_dev,
			const struct usb_device_id *id)
{}

/* -- start the camera -- */
static int sd_start(struct gspca_dev *gspca_dev)
{}

static void sd_stopN(struct gspca_dev *gspca_dev)
{}

/* this function is called at probe and resume time */
static int sd_init(struct gspca_dev *gspca_dev)
{}

static void sd_pkt_scan(struct gspca_dev *gspca_dev,
			u8 *data,
			int len)
{}

static void sd_dq_callback(struct gspca_dev *gspca_dev)
{}

static int sd_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops sd_ctrl_ops =;

static int sd_init_controls(struct gspca_dev *gspca_dev)
{}

/* sub-driver description */
static const struct sd_desc sd_desc =;

/* -- module initialisation -- */
static const struct usb_device_id device_table[] =;
MODULE_DEVICE_TABLE(usb, device_table);

/* -- 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();