162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher 462306a36Sopenharmony_ci * Mark Cave-Ayland, Carlo E Prelz, Dick Streefland 562306a36Sopenharmony_ci * Copyright (c) 2002, 2003 Tuukka Toivonen 662306a36Sopenharmony_ci * Copyright (c) 2008 Erik Andrén 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * P/N 861037: Sensor HDCS1000 ASIC STV0600 962306a36Sopenharmony_ci * P/N 861050-0010: Sensor HDCS1000 ASIC STV0600 1062306a36Sopenharmony_ci * P/N 861050-0020: Sensor Photobit PB100 ASIC STV0600-1 - QuickCam Express 1162306a36Sopenharmony_ci * P/N 861055: Sensor ST VV6410 ASIC STV0610 - LEGO cam 1262306a36Sopenharmony_ci * P/N 861075-0040: Sensor HDCS1000 ASIC 1362306a36Sopenharmony_ci * P/N 961179-0700: Sensor ST VV6410 ASIC STV0602 - Dexxa WebCam USB 1462306a36Sopenharmony_ci * P/N 861040-0000: Sensor ST VV6410 ASIC STV0610 - QuickCam Web 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#ifndef STV06XX_H_ 1862306a36Sopenharmony_ci#define STV06XX_H_ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#include <linux/slab.h> 2162306a36Sopenharmony_ci#include "gspca.h" 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define MODULE_NAME "STV06xx" 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define STV_ISOC_ENDPOINT_ADDR 0x81 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define STV_R 0x0509 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define STV_REG23 0x0423 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* Control registers of the STV0600 ASIC */ 3262306a36Sopenharmony_ci#define STV_I2C_PARTNER 0x1420 3362306a36Sopenharmony_ci#define STV_I2C_VAL_REG_VAL_PAIRS_MIN1 0x1421 3462306a36Sopenharmony_ci#define STV_I2C_READ_WRITE_TOGGLE 0x1422 3562306a36Sopenharmony_ci#define STV_I2C_FLUSH 0x1423 3662306a36Sopenharmony_ci#define STV_I2C_SUCC_READ_REG_VALS 0x1424 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define STV_ISO_ENABLE 0x1440 3962306a36Sopenharmony_ci#define STV_SCAN_RATE 0x1443 4062306a36Sopenharmony_ci#define STV_LED_CTRL 0x1445 4162306a36Sopenharmony_ci#define STV_STV0600_EMULATION 0x1446 4262306a36Sopenharmony_ci#define STV_REG00 0x1500 4362306a36Sopenharmony_ci#define STV_REG01 0x1501 4462306a36Sopenharmony_ci#define STV_REG02 0x1502 4562306a36Sopenharmony_ci#define STV_REG03 0x1503 4662306a36Sopenharmony_ci#define STV_REG04 0x1504 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define STV_ISO_SIZE_L 0x15c1 4962306a36Sopenharmony_ci#define STV_ISO_SIZE_H 0x15c2 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci/* Refers to the CIF 352x288 and QCIF 176x144 */ 5262306a36Sopenharmony_ci/* 1: 288 lines, 2: 144 lines */ 5362306a36Sopenharmony_ci#define STV_Y_CTRL 0x15c3 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#define STV_RESET 0x1620 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* 0xa: 352 columns, 0x6: 176 columns */ 5862306a36Sopenharmony_ci#define STV_X_CTRL 0x1680 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define STV06XX_URB_MSG_TIMEOUT 5000 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define I2C_MAX_BYTES 16 6362306a36Sopenharmony_ci#define I2C_MAX_WORDS 8 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define I2C_BUFFER_LENGTH 0x23 6662306a36Sopenharmony_ci#define I2C_READ_CMD 3 6762306a36Sopenharmony_ci#define I2C_WRITE_CMD 1 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define LED_ON 1 7062306a36Sopenharmony_ci#define LED_OFF 0 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* STV06xx device descriptor */ 7362306a36Sopenharmony_cistruct sd { 7462306a36Sopenharmony_ci struct gspca_dev gspca_dev; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci /* A pointer to the currently connected sensor */ 7762306a36Sopenharmony_ci const struct stv06xx_sensor *sensor; 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci /* Sensor private data */ 8062306a36Sopenharmony_ci void *sensor_priv; 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci /* The first 4 lines produced by the stv6422 are no good, this keeps 8362306a36Sopenharmony_ci track of how many bytes we still need to skip during a frame */ 8462306a36Sopenharmony_ci int to_skip; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci /* Bridge / Camera type */ 8762306a36Sopenharmony_ci u8 bridge; 8862306a36Sopenharmony_ci #define BRIDGE_STV600 0 8962306a36Sopenharmony_ci #define BRIDGE_STV602 1 9062306a36Sopenharmony_ci #define BRIDGE_STV610 2 9162306a36Sopenharmony_ci #define BRIDGE_ST6422 3 /* With integrated sensor */ 9262306a36Sopenharmony_ci}; 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ciint stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data); 9562306a36Sopenharmony_ciint stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciint stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len); 9862306a36Sopenharmony_ciint stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len); 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ciint stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value); 10162306a36Sopenharmony_ciint stv06xx_write_sensor(struct sd *sd, u8 address, u16 value); 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#endif 104