diff options
Diffstat (limited to 'drivers/media/video/gspca/m5602/m5602_bridge.h')
-rw-r--r-- | drivers/media/video/gspca/m5602/m5602_bridge.h | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_bridge.h b/drivers/media/video/gspca/m5602/m5602_bridge.h new file mode 100644 index 000000000000..c786d7d3d44a --- /dev/null +++ b/drivers/media/video/gspca/m5602/m5602_bridge.h | |||
@@ -0,0 +1,170 @@ | |||
1 | /* | ||
2 | * USB Driver for ALi m5602 based webcams | ||
3 | * | ||
4 | * Copyright (C) 2008 Erik Andren | ||
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> | ||
7 | * | ||
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 | ||
12 | * | ||
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. | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | #ifndef M5602_BRIDGE_H_ | ||
20 | #define M5602_BRIDGE_H_ | ||
21 | |||
22 | #include "gspca.h" | ||
23 | |||
24 | #define MODULE_NAME "ALi m5602" | ||
25 | |||
26 | /*****************************************************************************/ | ||
27 | |||
28 | #undef PDEBUG | ||
29 | #undef info | ||
30 | #undef err | ||
31 | |||
32 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | ||
33 | format "\n" , ## arg) | ||
34 | #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ | ||
35 | format "\n" , ## arg) | ||
36 | |||
37 | /* Debug parameters */ | ||
38 | #define DBG_INIT 0x1 | ||
39 | #define DBG_PROBE 0x2 | ||
40 | #define DBG_V4L2 0x4 | ||
41 | #define DBG_TRACE 0x8 | ||
42 | #define DBG_DATA 0x10 | ||
43 | #define DBG_V4L2_CID 0x20 | ||
44 | #define DBG_GSPCA 0x40 | ||
45 | |||
46 | #define PDEBUG(level, fmt, args...) \ | ||
47 | do { \ | ||
48 | if (m5602_debug & level) \ | ||
49 | info("[%s:%d] " fmt, __func__, __LINE__ , \ | ||
50 | ## args); \ | ||
51 | } while (0) | ||
52 | |||
53 | /*****************************************************************************/ | ||
54 | |||
55 | #define M5602_XB_SENSOR_TYPE 0x00 | ||
56 | #define M5602_XB_SENSOR_CTRL 0x01 | ||
57 | #define M5602_XB_LINE_OF_FRAME_H 0x02 | ||
58 | #define M5602_XB_LINE_OF_FRAME_L 0x03 | ||
59 | #define M5602_XB_PIX_OF_LINE_H 0x04 | ||
60 | #define M5602_XB_PIX_OF_LINE_L 0x05 | ||
61 | #define M5602_XB_VSYNC_PARA 0x06 | ||
62 | #define M5602_XB_HSYNC_PARA 0x07 | ||
63 | #define M5602_XB_TEST_MODE_1 0x08 | ||
64 | #define M5602_XB_TEST_MODE_2 0x09 | ||
65 | #define M5602_XB_SIG_INI 0x0a | ||
66 | #define M5602_XB_DS_PARA 0x0e | ||
67 | #define M5602_XB_TRIG_PARA 0x0f | ||
68 | #define M5602_XB_CLK_PD 0x10 | ||
69 | #define M5602_XB_MCU_CLK_CTRL 0x12 | ||
70 | #define M5602_XB_MCU_CLK_DIV 0x13 | ||
71 | #define M5602_XB_SEN_CLK_CTRL 0x14 | ||
72 | #define M5602_XB_SEN_CLK_DIV 0x15 | ||
73 | #define M5602_XB_AUD_CLK_CTRL 0x16 | ||
74 | #define M5602_XB_AUD_CLK_DIV 0x17 | ||
75 | #define M5602_XB_DEVCTR1 0x41 | ||
76 | #define M5602_XB_EPSETR0 0x42 | ||
77 | #define M5602_XB_EPAFCTR 0x47 | ||
78 | #define M5602_XB_EPBFCTR 0x49 | ||
79 | #define M5602_XB_EPEFCTR 0x4f | ||
80 | #define M5602_XB_TEST_REG 0x53 | ||
81 | #define M5602_XB_ALT2SIZE 0x54 | ||
82 | #define M5602_XB_ALT3SIZE 0x55 | ||
83 | #define M5602_XB_OBSFRAME 0x56 | ||
84 | #define M5602_XB_PWR_CTL 0x59 | ||
85 | #define M5602_XB_ADC_CTRL 0x60 | ||
86 | #define M5602_XB_ADC_DATA 0x61 | ||
87 | #define M5602_XB_MISC_CTRL 0x62 | ||
88 | #define M5602_XB_SNAPSHOT 0x63 | ||
89 | #define M5602_XB_SCRATCH_1 0x64 | ||
90 | #define M5602_XB_SCRATCH_2 0x65 | ||
91 | #define M5602_XB_SCRATCH_3 0x66 | ||
92 | #define M5602_XB_SCRATCH_4 0x67 | ||
93 | #define M5602_XB_I2C_CTRL 0x68 | ||
94 | #define M5602_XB_I2C_CLK_DIV 0x69 | ||
95 | #define M5602_XB_I2C_DEV_ADDR 0x6a | ||
96 | #define M5602_XB_I2C_REG_ADDR 0x6b | ||
97 | #define M5602_XB_I2C_DATA 0x6c | ||
98 | #define M5602_XB_I2C_STATUS 0x6d | ||
99 | #define M5602_XB_GPIO_DAT_H 0x70 | ||
100 | #define M5602_XB_GPIO_DAT_L 0x71 | ||
101 | #define M5602_XB_GPIO_DIR_H 0x72 | ||
102 | #define M5602_XB_GPIO_DIR_L 0x73 | ||
103 | #define M5602_XB_GPIO_EN_H 0x74 | ||
104 | #define M5602_XB_GPIO_EN_L 0x75 | ||
105 | #define M5602_XB_GPIO_DAT 0x76 | ||
106 | #define M5602_XB_GPIO_DIR 0x77 | ||
107 | #define M5602_XB_MISC_CTL 0x70 | ||
108 | |||
109 | #define I2C_BUSY 0x80 | ||
110 | |||
111 | /*****************************************************************************/ | ||
112 | |||
113 | /* Driver info */ | ||
114 | #define DRIVER_AUTHOR "ALi m5602 Linux Driver Project" | ||
115 | #define DRIVER_DESC "ALi m5602 webcam driver" | ||
116 | |||
117 | #define M5602_ISOC_ENDPOINT_ADDR 0x81 | ||
118 | #define M5602_INTR_ENDPOINT_ADDR 0x82 | ||
119 | |||
120 | #define M5602_MAX_FRAMES 32 | ||
121 | #define M5602_URBS 2 | ||
122 | #define M5602_ISOC_PACKETS 14 | ||
123 | |||
124 | #define M5602_URB_TIMEOUT msecs_to_jiffies(2 * M5602_ISOC_PACKETS) | ||
125 | #define M5602_URB_MSG_TIMEOUT 5000 | ||
126 | #define M5602_FRAME_TIMEOUT 2 | ||
127 | |||
128 | /*****************************************************************************/ | ||
129 | |||
130 | /* A skeleton used for sending messages to the m5602 bridge */ | ||
131 | static const unsigned char bridge_urb_skeleton[] = { | ||
132 | 0x13, 0x00, 0x81, 0x00 | ||
133 | }; | ||
134 | |||
135 | /* A skeleton used for sending messages to the sensor */ | ||
136 | static const unsigned char sensor_urb_skeleton[] = { | ||
137 | 0x23, M5602_XB_GPIO_EN_H, 0x81, 0x06, | ||
138 | 0x23, M5602_XB_MISC_CTRL, 0x81, 0x80, | ||
139 | 0x13, M5602_XB_I2C_DEV_ADDR, 0x81, 0x00, | ||
140 | 0x13, M5602_XB_I2C_REG_ADDR, 0x81, 0x00, | ||
141 | 0x13, M5602_XB_I2C_DATA, 0x81, 0x00, | ||
142 | 0x13, M5602_XB_I2C_CTRL, 0x81, 0x11 | ||
143 | }; | ||
144 | |||
145 | /* m5602 device descriptor, currently it just wraps the m5602_camera struct */ | ||
146 | struct sd { | ||
147 | struct gspca_dev gspca_dev; | ||
148 | |||
149 | /* The name of the m5602 camera */ | ||
150 | char *name; | ||
151 | |||
152 | /* A pointer to the currently connected sensor */ | ||
153 | struct m5602_sensor *sensor; | ||
154 | |||
155 | struct sd_desc *desc; | ||
156 | |||
157 | /* The current frame's id, used to detect frame boundaries */ | ||
158 | u8 frame_id; | ||
159 | |||
160 | /* The current frame count */ | ||
161 | u32 frame_count; | ||
162 | }; | ||
163 | |||
164 | int m5602_read_bridge( | ||
165 | struct sd *sd, u8 address, u8 *i2c_data); | ||
166 | |||
167 | int m5602_write_bridge( | ||
168 | struct sd *sd, u8 address, u8 i2c_data); | ||
169 | |||
170 | #endif | ||