1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef M5602_BRIDGE_H_
20#define M5602_BRIDGE_H_
21
22#include <linux/slab.h>
23#include "gspca.h"
24
25#define MODULE_NAME "ALi m5602"
26
27
28
29#define M5602_XB_SENSOR_TYPE 0x00
30#define M5602_XB_SENSOR_CTRL 0x01
31#define M5602_XB_LINE_OF_FRAME_H 0x02
32#define M5602_XB_LINE_OF_FRAME_L 0x03
33#define M5602_XB_PIX_OF_LINE_H 0x04
34#define M5602_XB_PIX_OF_LINE_L 0x05
35#define M5602_XB_VSYNC_PARA 0x06
36#define M5602_XB_HSYNC_PARA 0x07
37#define M5602_XB_TEST_MODE_1 0x08
38#define M5602_XB_TEST_MODE_2 0x09
39#define M5602_XB_SIG_INI 0x0a
40#define M5602_XB_DS_PARA 0x0e
41#define M5602_XB_TRIG_PARA 0x0f
42#define M5602_XB_CLK_PD 0x10
43#define M5602_XB_MCU_CLK_CTRL 0x12
44#define M5602_XB_MCU_CLK_DIV 0x13
45#define M5602_XB_SEN_CLK_CTRL 0x14
46#define M5602_XB_SEN_CLK_DIV 0x15
47#define M5602_XB_AUD_CLK_CTRL 0x16
48#define M5602_XB_AUD_CLK_DIV 0x17
49#define M5602_OB_AC_LINK_STATE 0x22
50#define M5602_OB_PCM_SLOT_INDEX 0x24
51#define M5602_OB_GPIO_SLOT_INDEX 0x25
52#define M5602_OB_ACRX_STATUS_ADDRESS_H 0x28
53#define M5602_OB_ACRX_STATUS_DATA_L 0x29
54#define M5602_OB_ACRX_STATUS_DATA_H 0x2a
55#define M5602_OB_ACTX_COMMAND_ADDRESS 0x31
56#define M5602_OB_ACRX_COMMAND_DATA_L 0x32
57#define M5602_OB_ACTX_COMMAND_DATA_H 0X33
58#define M5602_XB_DEVCTR1 0x41
59#define M5602_XB_EPSETR0 0x42
60#define M5602_XB_EPAFCTR 0x47
61#define M5602_XB_EPBFCTR 0x49
62#define M5602_XB_EPEFCTR 0x4f
63#define M5602_XB_TEST_REG 0x53
64#define M5602_XB_ALT2SIZE 0x54
65#define M5602_XB_ALT3SIZE 0x55
66#define M5602_XB_OBSFRAME 0x56
67#define M5602_XB_PWR_CTL 0x59
68#define M5602_XB_ADC_CTRL 0x60
69#define M5602_XB_ADC_DATA 0x61
70#define M5602_XB_MISC_CTRL 0x62
71#define M5602_XB_SNAPSHOT 0x63
72#define M5602_XB_SCRATCH_1 0x64
73#define M5602_XB_SCRATCH_2 0x65
74#define M5602_XB_SCRATCH_3 0x66
75#define M5602_XB_SCRATCH_4 0x67
76#define M5602_XB_I2C_CTRL 0x68
77#define M5602_XB_I2C_CLK_DIV 0x69
78#define M5602_XB_I2C_DEV_ADDR 0x6a
79#define M5602_XB_I2C_REG_ADDR 0x6b
80#define M5602_XB_I2C_DATA 0x6c
81#define M5602_XB_I2C_STATUS 0x6d
82#define M5602_XB_GPIO_DAT_H 0x70
83#define M5602_XB_GPIO_DAT_L 0x71
84#define M5602_XB_GPIO_DIR_H 0x72
85#define M5602_XB_GPIO_DIR_L 0x73
86#define M5602_XB_GPIO_EN_H 0x74
87#define M5602_XB_GPIO_EN_L 0x75
88#define M5602_XB_GPIO_DAT 0x76
89#define M5602_XB_GPIO_DIR 0x77
90#define M5602_XB_SEN_CLK_CONTROL 0x80
91#define M5602_XB_SEN_CLK_DIVISION 0x81
92#define M5602_XB_CPR_CLK_CONTROL 0x82
93#define M5602_XB_CPR_CLK_DIVISION 0x83
94#define M5602_XB_MCU_CLK_CONTROL 0x84
95#define M5602_XB_MCU_CLK_DIVISION 0x85
96#define M5602_XB_DCT_CLK_CONTROL 0x86
97#define M5602_XB_DCT_CLK_DIVISION 0x87
98#define M5602_XB_EC_CLK_CONTROL 0x88
99#define M5602_XB_EC_CLK_DIVISION 0x89
100#define M5602_XB_LBUF_CLK_CONTROL 0x8a
101#define M5602_XB_LBUF_CLK_DIVISION 0x8b
102
103#define I2C_BUSY 0x80
104
105
106
107
108#define DRIVER_AUTHOR "ALi m5602 Linux Driver Project"
109#define DRIVER_DESC "ALi m5602 webcam driver"
110
111#define M5602_ISOC_ENDPOINT_ADDR 0x81
112#define M5602_INTR_ENDPOINT_ADDR 0x82
113
114#define M5602_URB_MSG_TIMEOUT 5000
115
116
117
118struct sd {
119 struct gspca_dev gspca_dev;
120
121
122 const struct m5602_sensor *sensor;
123
124
125 u8 frame_id;
126
127
128 u32 frame_count;
129
130
131 struct task_struct *rotation_thread;
132
133 struct {
134 struct v4l2_ctrl *auto_white_bal;
135 struct v4l2_ctrl *red_bal;
136 struct v4l2_ctrl *blue_bal;
137 struct v4l2_ctrl *green_bal;
138 };
139 struct {
140 struct v4l2_ctrl *autoexpo;
141 struct v4l2_ctrl *expo;
142 };
143 struct {
144 struct v4l2_ctrl *autogain;
145 struct v4l2_ctrl *gain;
146 };
147 struct {
148 struct v4l2_ctrl *hflip;
149 struct v4l2_ctrl *vflip;
150 };
151};
152
153int m5602_read_bridge(
154 struct sd *sd, const u8 address, u8 *i2c_data);
155
156int m5602_write_bridge(
157 struct sd *sd, const u8 address, const u8 i2c_data);
158
159int m5602_write_sensor(struct sd *sd, const u8 address,
160 u8 *i2c_data, const u8 len);
161
162int m5602_read_sensor(struct sd *sd, const u8 address,
163 u8 *i2c_data, const u8 len);
164
165#endif
166