linux/drivers/media/usb/pwc/pwc.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/* (C) 1999-2003 Nemosoft Unv.
   (C) 2004-2006 Luc Saillard ([email protected])

   NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
   driver and thus may have bugs that are not present in the original version.
   Please send bug reports and support requests to <[email protected]>.
   The decompression routines have been implemented by reverse-engineering the
   Nemosoft binary pwcx module. Caveat emptor.

*/

#ifndef PWC_H
#define PWC_H

#include <linux/module.h>
#include <linux/usb.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <asm/errno.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-v4l2.h>
#include <media/videobuf2-vmalloc.h>
#ifdef CONFIG_USB_PWC_INPUT_EVDEV
#include <linux/input.h>
#endif
#include "pwc-dec1.h"
#include "pwc-dec23.h"

/* Version block */
#define PWC_VERSION
#define PWC_NAME
#define PFX


/* Trace certain actions in the driver */
#define PWC_DEBUG_LEVEL_MODULE
#define PWC_DEBUG_LEVEL_PROBE
#define PWC_DEBUG_LEVEL_OPEN
#define PWC_DEBUG_LEVEL_READ
#define PWC_DEBUG_LEVEL_MEMORY
#define PWC_DEBUG_LEVEL_FLOW
#define PWC_DEBUG_LEVEL_SIZE
#define PWC_DEBUG_LEVEL_IOCTL
#define PWC_DEBUG_LEVEL_TRACE

#define PWC_DEBUG_MODULE(fmt, args...)
#define PWC_DEBUG_PROBE(fmt, args...)
#define PWC_DEBUG_OPEN(fmt, args...)
#define PWC_DEBUG_READ(fmt, args...)
#define PWC_DEBUG_MEMORY(fmt, args...)
#define PWC_DEBUG_FLOW(fmt, args...)
#define PWC_DEBUG_SIZE(fmt, args...)
#define PWC_DEBUG_IOCTL(fmt, args...)
#define PWC_DEBUG_TRACE(fmt, args...)


#ifdef CONFIG_USB_PWC_DEBUG

#define PWC_DEBUG_LEVEL

#define PWC_DEBUG(level, fmt, args...)

#define PWC_ERROR(fmt, args...)
#define PWC_WARNING(fmt, args...)
#define PWC_INFO(fmt, args...)
#define PWC_TRACE(fmt, args...)

#else /* if ! CONFIG_USB_PWC_DEBUG */

#define PWC_ERROR
#define PWC_WARNING
#define PWC_INFO
#define PWC_TRACE
#define PWC_DEBUG

#define pwc_trace

#endif

/* Defines for ToUCam cameras */
#define TOUCAM_HEADER_SIZE
#define TOUCAM_TRAILER_SIZE

#define FEATURE_MOTOR_PANTILT
#define FEATURE_CODEC1
#define FEATURE_CODEC2

#define MAX_WIDTH
#define MAX_HEIGHT

/* Ignore errors in the first N frames, to allow for startup delays */
#define FRAME_LOWMARK

/* Size and number of buffers for the ISO pipe. */
#define MAX_ISO_BUFS
#define ISO_FRAMES_PER_DESC
#define ISO_MAX_FRAME_SIZE
#define ISO_BUFFER_SIZE

/* Maximum size after decompression is 640x480 YUV data, 1.5 * 640 * 480 */
#define PWC_FRAME_SIZE

/* Absolute minimum and maximum number of buffers available for mmap() */
#define MIN_FRAMES
#define MAX_FRAMES

/* Some macros to quickly find the type of a webcam */
#define DEVICE_USE_CODEC1(x)
#define DEVICE_USE_CODEC2(x)
#define DEVICE_USE_CODEC3(x)
#define DEVICE_USE_CODEC23(x)

/* Request types: video */
#define SET_LUM_CTL
#define GET_LUM_CTL
#define SET_CHROM_CTL
#define GET_CHROM_CTL
#define SET_STATUS_CTL
#define GET_STATUS_CTL
#define SET_EP_STREAM_CTL
#define GET_EP_STREAM_CTL
#define GET_XX_CTL
#define SET_XX_CTL
#define GET_XY_CTL
#define SET_XY_CTL
#define SET_MPT_CTL
#define GET_MPT_CTL

/* Selectors for the Luminance controls [GS]ET_LUM_CTL */
#define AGC_MODE_FORMATTER
#define PRESET_AGC_FORMATTER
#define SHUTTER_MODE_FORMATTER
#define PRESET_SHUTTER_FORMATTER
#define PRESET_CONTOUR_FORMATTER
#define AUTO_CONTOUR_FORMATTER
#define BACK_LIGHT_COMPENSATION_FORMATTER
#define CONTRAST_FORMATTER
#define DYNAMIC_NOISE_CONTROL_FORMATTER
#define FLICKERLESS_MODE_FORMATTER
#define AE_CONTROL_SPEED
#define BRIGHTNESS_FORMATTER
#define GAMMA_FORMATTER

/* Selectors for the Chrominance controls [GS]ET_CHROM_CTL */
#define WB_MODE_FORMATTER
#define AWB_CONTROL_SPEED_FORMATTER
#define AWB_CONTROL_DELAY_FORMATTER
#define PRESET_MANUAL_RED_GAIN_FORMATTER
#define PRESET_MANUAL_BLUE_GAIN_FORMATTER
#define COLOUR_MODE_FORMATTER
#define SATURATION_MODE_FORMATTER1
#define SATURATION_MODE_FORMATTER2

/* Selectors for the Status controls [GS]ET_STATUS_CTL */
#define SAVE_USER_DEFAULTS_FORMATTER
#define RESTORE_USER_DEFAULTS_FORMATTER
#define RESTORE_FACTORY_DEFAULTS_FORMATTER
#define READ_AGC_FORMATTER
#define READ_SHUTTER_FORMATTER
#define READ_RED_GAIN_FORMATTER
#define READ_BLUE_GAIN_FORMATTER

/* Formatters for the motorized pan & tilt [GS]ET_MPT_CTL */
#define PT_RELATIVE_CONTROL_FORMATTER
#define PT_RESET_CONTROL_FORMATTER
#define PT_STATUS_FORMATTER

/* Enumeration of image sizes */
#define PSZ_SQCIF
#define PSZ_QSIF
#define PSZ_QCIF
#define PSZ_SIF
#define PSZ_CIF
#define PSZ_VGA
#define PSZ_MAX

struct pwc_raw_frame {} __packed;

/* intermediate buffers with raw data from the USB cam */
struct pwc_frame_buf
{};

struct pwc_device
{};

/* Global variables */
#ifdef CONFIG_USB_PWC_DEBUG
extern int pwc_trace;
#endif

/** Functions in pwc-misc.c */
/* sizes in pixels */
extern const int pwc_image_sizes[PSZ_MAX][2];

int pwc_get_size(struct pwc_device *pdev, int width, int height);
void pwc_construct(struct pwc_device *pdev);

/** Functions in pwc-ctrl.c */
/* Request a certain video mode. Returns < 0 if not possible */
extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
	int pixfmt, int frames, int *compression, int send_to_cam);
extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size);
extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
extern int send_control_msg(struct pwc_device *pdev,
			    u8 request, u16 value, void *buf, int buflen);

/* Control get / set helpers */
int pwc_get_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data);
int pwc_set_u8_ctrl(struct pwc_device *pdev, u8 request, u16 value, u8 data);
int pwc_get_s8_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *data);
#define pwc_set_s8_ctrl
int pwc_get_u16_ctrl(struct pwc_device *pdev, u8 request, u16 value, int *dat);
int pwc_set_u16_ctrl(struct pwc_device *pdev, u8 request, u16 value, u16 data);
int pwc_button_ctrl(struct pwc_device *pdev, u16 value);
int pwc_init_controls(struct pwc_device *pdev);

/* Power down or up the camera; not supported by all models */
extern void pwc_camera_power(struct pwc_device *pdev, int power);

extern const struct v4l2_ioctl_ops pwc_ioctl_ops;

/** pwc-uncompress.c */
/* Expand frame to image, possibly including decompression. Uses read_frame and fill_image */
int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf);

#endif