xref: /OK3568_Linux_fs/kernel/drivers/media/usb/gspca/stv06xx/stv06xx.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2001 Jean-Fredric Clere, Nikolas Zimmermann, Georg Acher
4*4882a593Smuzhiyun  *		      Mark Cave-Ayland, Carlo E Prelz, Dick Streefland
5*4882a593Smuzhiyun  * Copyright (c) 2002, 2003 Tuukka Toivonen
6*4882a593Smuzhiyun  * Copyright (c) 2008 Erik Andrén
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * P/N 861037:      Sensor HDCS1000        ASIC STV0600
9*4882a593Smuzhiyun  * P/N 861050-0010: Sensor HDCS1000        ASIC STV0600
10*4882a593Smuzhiyun  * P/N 861050-0020: Sensor Photobit PB100  ASIC STV0600-1 - QuickCam Express
11*4882a593Smuzhiyun  * P/N 861055:      Sensor ST VV6410       ASIC STV0610   - LEGO cam
12*4882a593Smuzhiyun  * P/N 861075-0040: Sensor HDCS1000        ASIC
13*4882a593Smuzhiyun  * P/N 961179-0700: Sensor ST VV6410       ASIC STV0602   - Dexxa WebCam USB
14*4882a593Smuzhiyun  * P/N 861040-0000: Sensor ST VV6410       ASIC STV0610   - QuickCam Web
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #ifndef STV06XX_H_
18*4882a593Smuzhiyun #define STV06XX_H_
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #include <linux/slab.h>
21*4882a593Smuzhiyun #include "gspca.h"
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun #define MODULE_NAME "STV06xx"
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun #define STV_ISOC_ENDPOINT_ADDR		0x81
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #define STV_R                           0x0509
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #define STV_REG23			0x0423
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun /* Control registers of the STV0600 ASIC */
32*4882a593Smuzhiyun #define STV_I2C_PARTNER			0x1420
33*4882a593Smuzhiyun #define STV_I2C_VAL_REG_VAL_PAIRS_MIN1	0x1421
34*4882a593Smuzhiyun #define STV_I2C_READ_WRITE_TOGGLE	0x1422
35*4882a593Smuzhiyun #define STV_I2C_FLUSH			0x1423
36*4882a593Smuzhiyun #define STV_I2C_SUCC_READ_REG_VALS	0x1424
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #define STV_ISO_ENABLE			0x1440
39*4882a593Smuzhiyun #define STV_SCAN_RATE			0x1443
40*4882a593Smuzhiyun #define STV_LED_CTRL			0x1445
41*4882a593Smuzhiyun #define STV_STV0600_EMULATION		0x1446
42*4882a593Smuzhiyun #define STV_REG00			0x1500
43*4882a593Smuzhiyun #define STV_REG01			0x1501
44*4882a593Smuzhiyun #define STV_REG02			0x1502
45*4882a593Smuzhiyun #define STV_REG03			0x1503
46*4882a593Smuzhiyun #define STV_REG04			0x1504
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #define STV_ISO_SIZE_L			0x15c1
49*4882a593Smuzhiyun #define STV_ISO_SIZE_H			0x15c2
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun /* Refers to the CIF 352x288 and QCIF 176x144 */
52*4882a593Smuzhiyun /* 1: 288 lines, 2: 144 lines */
53*4882a593Smuzhiyun #define STV_Y_CTRL			0x15c3
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun #define STV_RESET                       0x1620
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun /* 0xa: 352 columns, 0x6: 176 columns */
58*4882a593Smuzhiyun #define STV_X_CTRL			0x1680
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #define STV06XX_URB_MSG_TIMEOUT		5000
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun #define I2C_MAX_BYTES			16
63*4882a593Smuzhiyun #define I2C_MAX_WORDS			8
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun #define I2C_BUFFER_LENGTH		0x23
66*4882a593Smuzhiyun #define I2C_READ_CMD			3
67*4882a593Smuzhiyun #define I2C_WRITE_CMD			1
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #define LED_ON				1
70*4882a593Smuzhiyun #define LED_OFF				0
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /* STV06xx device descriptor */
73*4882a593Smuzhiyun struct sd {
74*4882a593Smuzhiyun 	struct gspca_dev gspca_dev;
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	/* A pointer to the currently connected sensor */
77*4882a593Smuzhiyun 	const struct stv06xx_sensor *sensor;
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun 	/* Sensor private data */
80*4882a593Smuzhiyun 	void *sensor_priv;
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun 	/* The first 4 lines produced by the stv6422 are no good, this keeps
83*4882a593Smuzhiyun 	   track of how many bytes we still need to skip during a frame */
84*4882a593Smuzhiyun 	int to_skip;
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun 	/* Bridge / Camera type */
87*4882a593Smuzhiyun 	u8 bridge;
88*4882a593Smuzhiyun 	#define BRIDGE_STV600 0
89*4882a593Smuzhiyun 	#define BRIDGE_STV602 1
90*4882a593Smuzhiyun 	#define BRIDGE_STV610 2
91*4882a593Smuzhiyun 	#define BRIDGE_ST6422 3 /* With integrated sensor */
92*4882a593Smuzhiyun };
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun int stv06xx_write_bridge(struct sd *sd, u16 address, u16 i2c_data);
95*4882a593Smuzhiyun int stv06xx_read_bridge(struct sd *sd, u16 address, u8 *i2c_data);
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun int stv06xx_write_sensor_bytes(struct sd *sd, const u8 *data, u8 len);
98*4882a593Smuzhiyun int stv06xx_write_sensor_words(struct sd *sd, const u16 *data, u8 len);
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun int stv06xx_read_sensor(struct sd *sd, const u8 address, u16 *value);
101*4882a593Smuzhiyun int stv06xx_write_sensor(struct sd *sd, u8 address, u16 value);
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun #endif
104