2 * USB Driver for ALi m5602 based webcams
4 * Copyright (C) 2008 Erik Andrén
5 * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
6 * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
8 * Portions of code to USB interface and ALi driver software,
9 * Copyright (c) 2006 Willem Duinker
10 * v4l2 interface modeled after the V4L2 driver
11 * for SN9C10x PC Camera Controllers
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation, version 2.
19 #ifndef M5602_BRIDGE_H_
20 #define M5602_BRIDGE_H_
24 #define MODULE_NAME "ALi m5602"
26 /*****************************************************************************/
28 #define M5602_XB_SENSOR_TYPE 0x00
29 #define M5602_XB_SENSOR_CTRL 0x01
30 #define M5602_XB_LINE_OF_FRAME_H 0x02
31 #define M5602_XB_LINE_OF_FRAME_L 0x03
32 #define M5602_XB_PIX_OF_LINE_H 0x04
33 #define M5602_XB_PIX_OF_LINE_L 0x05
34 #define M5602_XB_VSYNC_PARA 0x06
35 #define M5602_XB_HSYNC_PARA 0x07
36 #define M5602_XB_TEST_MODE_1 0x08
37 #define M5602_XB_TEST_MODE_2 0x09
38 #define M5602_XB_SIG_INI 0x0a
39 #define M5602_XB_DS_PARA 0x0e
40 #define M5602_XB_TRIG_PARA 0x0f
41 #define M5602_XB_CLK_PD 0x10
42 #define M5602_XB_MCU_CLK_CTRL 0x12
43 #define M5602_XB_MCU_CLK_DIV 0x13
44 #define M5602_XB_SEN_CLK_CTRL 0x14
45 #define M5602_XB_SEN_CLK_DIV 0x15
46 #define M5602_XB_AUD_CLK_CTRL 0x16
47 #define M5602_XB_AUD_CLK_DIV 0x17
48 #define M5602_XB_DEVCTR1 0x41
49 #define M5602_XB_EPSETR0 0x42
50 #define M5602_XB_EPAFCTR 0x47
51 #define M5602_XB_EPBFCTR 0x49
52 #define M5602_XB_EPEFCTR 0x4f
53 #define M5602_XB_TEST_REG 0x53
54 #define M5602_XB_ALT2SIZE 0x54
55 #define M5602_XB_ALT3SIZE 0x55
56 #define M5602_XB_OBSFRAME 0x56
57 #define M5602_XB_PWR_CTL 0x59
58 #define M5602_XB_ADC_CTRL 0x60
59 #define M5602_XB_ADC_DATA 0x61
60 #define M5602_XB_MISC_CTRL 0x62
61 #define M5602_XB_SNAPSHOT 0x63
62 #define M5602_XB_SCRATCH_1 0x64
63 #define M5602_XB_SCRATCH_2 0x65
64 #define M5602_XB_SCRATCH_3 0x66
65 #define M5602_XB_SCRATCH_4 0x67
66 #define M5602_XB_I2C_CTRL 0x68
67 #define M5602_XB_I2C_CLK_DIV 0x69
68 #define M5602_XB_I2C_DEV_ADDR 0x6a
69 #define M5602_XB_I2C_REG_ADDR 0x6b
70 #define M5602_XB_I2C_DATA 0x6c
71 #define M5602_XB_I2C_STATUS 0x6d
72 #define M5602_XB_GPIO_DAT_H 0x70
73 #define M5602_XB_GPIO_DAT_L 0x71
74 #define M5602_XB_GPIO_DIR_H 0x72
75 #define M5602_XB_GPIO_DIR_L 0x73
76 #define M5602_XB_GPIO_EN_H 0x74
77 #define M5602_XB_GPIO_EN_L 0x75
78 #define M5602_XB_GPIO_DAT 0x76
79 #define M5602_XB_GPIO_DIR 0x77
80 #define M5602_XB_MISC_CTL 0x70
84 /*****************************************************************************/
87 #define DRIVER_AUTHOR "ALi m5602 Linux Driver Project"
88 #define DRIVER_DESC "ALi m5602 webcam driver"
90 #define M5602_ISOC_ENDPOINT_ADDR 0x81
91 #define M5602_INTR_ENDPOINT_ADDR 0x82
93 #define M5602_URB_MSG_TIMEOUT 5000
95 /*****************************************************************************/
97 /* A skeleton used for sending messages to the m5602 bridge */
98 static const unsigned char bridge_urb_skeleton[] = {
99 0x13, 0x00, 0x81, 0x00
102 /* A skeleton used for sending messages to the sensor */
103 static const unsigned char sensor_urb_skeleton[] = {
104 0x23, M5602_XB_GPIO_EN_H, 0x81, 0x06,
105 0x23, M5602_XB_MISC_CTRL, 0x81, 0x80,
106 0x13, M5602_XB_I2C_DEV_ADDR, 0x81, 0x00,
107 0x13, M5602_XB_I2C_REG_ADDR, 0x81, 0x00,
108 0x13, M5602_XB_I2C_DATA, 0x81, 0x00,
109 0x13, M5602_XB_I2C_CTRL, 0x81, 0x11
113 struct gspca_dev gspca_dev;
115 /* A pointer to the currently connected sensor */
116 const struct m5602_sensor *sensor;
118 struct sd_desc *desc;
120 /* The current frame's id, used to detect frame boundaries */
123 /* The current frame count */
127 int m5602_read_bridge(
128 struct sd *sd, u8 address, u8 *i2c_data);
130 int m5602_write_bridge(
131 struct sd *sd, u8 address, u8 i2c_data);
133 int m5602_write_sensor(struct sd *sd, const u8 address,
134 u8 *i2c_data, const u8 len);
136 int m5602_read_sensor(struct sd *sd, const u8 address,
137 u8 *i2c_data, const u8 len);