aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx231xx/cx231xx.h
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-03-03 04:14:34 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-04-06 20:44:01 -0400
commit84b5dbf39ed2f51224841bbbf08439158d69d427 (patch)
treeb24963462dc1ad93860645d8729d1ddfc6ce526e /drivers/media/video/cx231xx/cx231xx.h
parente0d3bafd02586cfde286c320f56906fd9fa8d256 (diff)
V4L/DVB (10955): cx231xx: CodingStyle automatic fixes with Lindent
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx.h')
-rw-r--r--drivers/media/video/cx231xx/cx231xx.h522
1 files changed, 260 insertions, 262 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h
index 5fef87fbbcec..1f6c5be65a55 100644
--- a/drivers/media/video/cx231xx/cx231xx.h
+++ b/drivers/media/video/cx231xx/cx231xx.h
@@ -2,7 +2,7 @@
2 cx231xx.h - driver for Conexant Cx23100/101/102 USB video capture devices 2 cx231xx.h - driver for Conexant Cx23100/101/102 USB video capture devices
3 3
4 Copyright (C) 2008 <srinivasa.deevi at conexant dot com> 4 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
5 Based on em28xx driver 5 Based on em28xx driver
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -65,7 +65,7 @@
65 65
66/* Params for validated field */ 66/* Params for validated field */
67#define CX231XX_BOARD_NOT_VALIDATED 1 67#define CX231XX_BOARD_NOT_VALIDATED 1
68#define CX231XX_BOARD_VALIDATED 0 68#define CX231XX_BOARD_VALIDATED 0
69 69
70/* maximum number of cx231xx boards */ 70/* maximum number of cx231xx boards */
71#define CX231XX_MAXBOARDS 8 71#define CX231XX_MAXBOARDS 8
@@ -82,17 +82,14 @@
82 */ 82 */
83#define CX231XX_NUM_PACKETS 40 83#define CX231XX_NUM_PACKETS 40
84 84
85
86/* default alternate; 0 means choose the best */ 85/* default alternate; 0 means choose the best */
87#define CX231XX_PINOUT 0 86#define CX231XX_PINOUT 0
88 87
89#define CX231XX_INTERLACED_DEFAULT 1 88#define CX231XX_INTERLACED_DEFAULT 1
90 89
91
92/* time to wait when stopping the isoc transfer */ 90/* time to wait when stopping the isoc transfer */
93#define CX231XX_URB_TIMEOUT msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS) 91#define CX231XX_URB_TIMEOUT msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS)
94 92
95
96enum cx231xx_mode { 93enum cx231xx_mode {
97 CX231XX_SUSPEND, 94 CX231XX_SUSPEND,
98 CX231XX_ANALOG_MODE, 95 CX231XX_ANALOG_MODE,
@@ -113,47 +110,45 @@ enum cx231xx_stream_state {
113struct cx231xx; 110struct cx231xx;
114 111
115struct cx231xx_usb_isoc_ctl { 112struct cx231xx_usb_isoc_ctl {
116 /* max packet size of isoc transaction */ 113 /* max packet size of isoc transaction */
117 int max_pkt_size; 114 int max_pkt_size;
118 115
119 /* number of allocated urbs */ 116 /* number of allocated urbs */
120 int num_bufs; 117 int num_bufs;
121 118
122 /* urb for isoc transfers */ 119 /* urb for isoc transfers */
123 struct urb **urb; 120 struct urb **urb;
124 121
125 /* transfer buffers for isoc transfer */ 122 /* transfer buffers for isoc transfer */
126 char **transfer_buffer; 123 char **transfer_buffer;
127 124
128 /* Last buffer command and region */ 125 /* Last buffer command and region */
129 u8 cmd; 126 u8 cmd;
130 int pos, size, pktsize; 127 int pos, size, pktsize;
131 128
132 /* Last field: ODD or EVEN? */ 129 /* Last field: ODD or EVEN? */
133 int field; 130 int field;
134 131
135 /* Stores incomplete commands */ 132 /* Stores incomplete commands */
136 u32 tmp_buf; 133 u32 tmp_buf;
137 int tmp_buf_len; 134 int tmp_buf_len;
138 135
139 /* Stores already requested buffers */ 136 /* Stores already requested buffers */
140 struct cx231xx_buffer *buf; 137 struct cx231xx_buffer *buf;
141 138
142 /* Stores the number of received fields */ 139 /* Stores the number of received fields */
143 int nfields; 140 int nfields;
144 141
145 /* isoc urb callback */ 142 /* isoc urb callback */
146 int (*isoc_copy) (struct cx231xx *dev, struct urb *urb); 143 int (*isoc_copy) (struct cx231xx * dev, struct urb * urb);
147 144
148}; 145};
149 146
150
151
152struct cx231xx_fmt { 147struct cx231xx_fmt {
153 char *name; 148 char *name;
154 u32 fourcc; /* v4l2 format id */ 149 u32 fourcc; /* v4l2 format id */
155 int depth; 150 int depth;
156 int reg; 151 int reg;
157}; 152};
158 153
159/* buffer for one video frame */ 154/* buffer for one video frame */
@@ -167,24 +162,23 @@ struct cx231xx_buffer {
167}; 162};
168 163
169struct cx231xx_dmaqueue { 164struct cx231xx_dmaqueue {
170 struct list_head active; 165 struct list_head active;
171 struct list_head queued; 166 struct list_head queued;
172 167
173 wait_queue_head_t wq; 168 wait_queue_head_t wq;
174 169
175 /* Counters to control buffer fill */ 170 /* Counters to control buffer fill */
176 int pos; 171 int pos;
177 u8 is_partial_line; 172 u8 is_partial_line;
178 u8 partial_buf[8]; 173 u8 partial_buf[8];
179 u8 last_sav; 174 u8 last_sav;
180 int current_field; 175 int current_field;
181 u32 bytes_left_in_line; 176 u32 bytes_left_in_line;
182 u32 lines_completed; 177 u32 lines_completed;
183 u8 field1_done; 178 u8 field1_done;
184 u32 lines_per_field; 179 u32 lines_per_field;
185}; 180};
186 181
187
188/* inputs */ 182/* inputs */
189 183
190#define MAX_CX231XX_INPUT 4 184#define MAX_CX231XX_INPUT 4
@@ -193,35 +187,35 @@ enum cx231xx_itype {
193 CX231XX_VMUX_COMPOSITE1 = 1, 187 CX231XX_VMUX_COMPOSITE1 = 1,
194 CX231XX_VMUX_SVIDEO, 188 CX231XX_VMUX_SVIDEO,
195 CX231XX_VMUX_TELEVISION, 189 CX231XX_VMUX_TELEVISION,
196 CX231XX_VMUX_CABLE, 190 CX231XX_VMUX_CABLE,
197 CX231XX_RADIO, 191 CX231XX_RADIO,
198 CX231XX_VMUX_DVB, 192 CX231XX_VMUX_DVB,
199 CX231XX_VMUX_DEBUG 193 CX231XX_VMUX_DEBUG
200}; 194};
201 195
202enum cx231xx_v_input { 196enum cx231xx_v_input {
203 CX231XX_VIN_1_1 = 0x1, 197 CX231XX_VIN_1_1 = 0x1,
204 CX231XX_VIN_2_1, 198 CX231XX_VIN_2_1,
205 CX231XX_VIN_3_1, 199 CX231XX_VIN_3_1,
206 CX231XX_VIN_4_1, 200 CX231XX_VIN_4_1,
207 CX231XX_VIN_1_2 = 0x01, 201 CX231XX_VIN_1_2 = 0x01,
208 CX231XX_VIN_2_2, 202 CX231XX_VIN_2_2,
209 CX231XX_VIN_3_2, 203 CX231XX_VIN_3_2,
210 CX231XX_VIN_1_3 = 0x1, 204 CX231XX_VIN_1_3 = 0x1,
211 CX231XX_VIN_2_3, 205 CX231XX_VIN_2_3,
212 CX231XX_VIN_3_3, 206 CX231XX_VIN_3_3,
213}; 207};
214 208
215/* cx231xx has two audio inputs: tuner and line in */ 209/* cx231xx has two audio inputs: tuner and line in */
216enum cx231xx_amux { 210enum cx231xx_amux {
217 /* This is the only entry for cx231xx tuner input */ 211 /* This is the only entry for cx231xx tuner input */
218 CX231XX_AMUX_VIDEO, /* cx231xx tuner*/ 212 CX231XX_AMUX_VIDEO, /* cx231xx tuner */
219 CX231XX_AMUX_LINE_IN, /* Line In */ 213 CX231XX_AMUX_LINE_IN, /* Line In */
220}; 214};
221 215
222struct cx231xx_reg_seq { 216struct cx231xx_reg_seq {
223 unsigned char bit; 217 unsigned char bit;
224 unsigned char val; 218 unsigned char val;
225 int sleep; 219 int sleep;
226}; 220};
227 221
@@ -239,41 +233,40 @@ enum cx231xx_decoder {
239 CX231XX_AVDECODER 233 CX231XX_AVDECODER
240}; 234};
241 235
242typedef enum _I2C_MASTER_PORT 236typedef enum _I2C_MASTER_PORT {
243{ 237 I2C_0 = 0,
244 I2C_0 =0, 238 I2C_1 = 1,
245 I2C_1 =1, 239 I2C_2 = 2,
246 I2C_2 =2, 240 I2C_3 = 3
247 I2C_3 =3 241} CX231XX_I2C_MASTER_PORT;
248}CX231XX_I2C_MASTER_PORT;
249 242
250struct cx231xx_board { 243struct cx231xx_board {
251 char *name; 244 char *name;
252 int vchannels; 245 int vchannels;
253 int tuner_type; 246 int tuner_type;
254 int tuner_addr; 247 int tuner_addr;
255 v4l2_std_id norm; /* tv norm */ 248 v4l2_std_id norm; /* tv norm */
256 249
257 /* demod related */ 250 /* demod related */
258 int demod_addr; 251 int demod_addr;
259 u8 demod_xfer_mode; /* 0 - Serial; 1 - parallel */ 252 u8 demod_xfer_mode; /* 0 - Serial; 1 - parallel */
260 253
261 /* GPIO Pins */ 254 /* GPIO Pins */
262 struct cx231xx_reg_seq *dvb_gpio; 255 struct cx231xx_reg_seq *dvb_gpio;
263 struct cx231xx_reg_seq *suspend_gpio; 256 struct cx231xx_reg_seq *suspend_gpio;
264 struct cx231xx_reg_seq *tuner_gpio; 257 struct cx231xx_reg_seq *tuner_gpio;
265 u8 tuner_sif_gpio; 258 u8 tuner_sif_gpio;
266 u8 tuner_scl_gpio; 259 u8 tuner_scl_gpio;
267 u8 tuner_sda_gpio; 260 u8 tuner_sda_gpio;
268 261
269 /* PIN ctrl */ 262 /* PIN ctrl */
270 u32 ctl_pin_status_mask; 263 u32 ctl_pin_status_mask;
271 u8 agc_analog_digital_select_gpio; 264 u8 agc_analog_digital_select_gpio;
272 u32 gpio_pin_status_mask; 265 u32 gpio_pin_status_mask;
273 266
274 /* i2c masters */ 267 /* i2c masters */
275 u8 tuner_i2c_master; 268 u8 tuner_i2c_master;
276 u8 demod_i2c_master; 269 u8 demod_i2c_master;
277 270
278 unsigned int max_range_640_480:1; 271 unsigned int max_range_640_480:1;
279 unsigned int has_dvb:1; 272 unsigned int has_dvb:1;
@@ -283,9 +276,9 @@ struct cx231xx_board {
283 276
284 enum cx231xx_decoder decoder; 277 enum cx231xx_decoder decoder;
285 278
286 struct cx231xx_input input[MAX_CX231XX_INPUT]; 279 struct cx231xx_input input[MAX_CX231XX_INPUT];
287 struct cx231xx_input radio; 280 struct cx231xx_input radio;
288 IR_KEYTAB_TYPE *ir_codes; 281 IR_KEYTAB_TYPE *ir_codes;
289}; 282};
290 283
291/* device states */ 284/* device states */
@@ -295,22 +288,20 @@ enum cx231xx_dev_state {
295 DEV_MISCONFIGURED = 0x04, 288 DEV_MISCONFIGURED = 0x04,
296}; 289};
297 290
298enum AFE_MODE 291enum AFE_MODE {
299{ 292 AFE_MODE_LOW_IF,
300 AFE_MODE_LOW_IF, 293 AFE_MODE_BASEBAND,
301 AFE_MODE_BASEBAND, 294 AFE_MODE_EU_HI_IF,
302 AFE_MODE_EU_HI_IF, 295 AFE_MODE_US_HI_IF,
303 AFE_MODE_US_HI_IF, 296 AFE_MODE_JAPAN_HI_IF
304 AFE_MODE_JAPAN_HI_IF
305}; 297};
306 298
307enum AUDIO_INPUT 299enum AUDIO_INPUT {
308{ 300 AUDIO_INPUT_MUTE,
309 AUDIO_INPUT_MUTE, 301 AUDIO_INPUT_LINE,
310 AUDIO_INPUT_LINE, 302 AUDIO_INPUT_TUNER_TV,
311 AUDIO_INPUT_TUNER_TV, 303 AUDIO_INPUT_SPDIF,
312 AUDIO_INPUT_SPDIF, 304 AUDIO_INPUT_TUNER_FM
313 AUDIO_INPUT_TUNER_FM
314}; 305};
315 306
316#define CX231XX_AUDIO_BUFS 5 307#define CX231XX_AUDIO_BUFS 5
@@ -319,7 +310,6 @@ enum AUDIO_INPUT
319#define CX231XX_STOP_AUDIO 0 310#define CX231XX_STOP_AUDIO 0
320#define CX231XX_START_AUDIO 1 311#define CX231XX_START_AUDIO 1
321 312
322
323/* cx231xx extensions */ 313/* cx231xx extensions */
324#define CX231XX_AUDIO 0x10 314#define CX231XX_AUDIO 0x10
325#define CX231XX_DVB 0x20 315#define CX231XX_DVB 0x20
@@ -330,169 +320,167 @@ struct cx231xx_audio {
330 struct urb *urb[CX231XX_AUDIO_BUFS]; 320 struct urb *urb[CX231XX_AUDIO_BUFS];
331 struct usb_device *udev; 321 struct usb_device *udev;
332 unsigned int capture_transfer_done; 322 unsigned int capture_transfer_done;
333 struct snd_pcm_substream *capture_pcm_substream; 323 struct snd_pcm_substream *capture_pcm_substream;
334 324
335 unsigned int hwptr_done_capture; 325 unsigned int hwptr_done_capture;
336 struct snd_card *sndcard; 326 struct snd_card *sndcard;
337 327
338 int users, shutdown; 328 int users, shutdown;
339 enum cx231xx_stream_state capture_stream; 329 enum cx231xx_stream_state capture_stream;
340 spinlock_t slock; 330 spinlock_t slock;
341 331
342 int alt; /* alternate */ 332 int alt; /* alternate */
343 int max_pkt_size; /* max packet size of isoc transaction */ 333 int max_pkt_size; /* max packet size of isoc transaction */
344 int num_alt; /* Number of alternative settings */ 334 int num_alt; /* Number of alternative settings */
345 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 335 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
346 u16 end_point_addr; 336 u16 end_point_addr;
347}; 337};
348 338
349struct cx231xx; 339struct cx231xx;
350 340
351struct cx231xx_fh { 341struct cx231xx_fh {
352 struct cx231xx *dev; 342 struct cx231xx *dev;
353 unsigned int stream_on:1; /* Locks streams */ 343 unsigned int stream_on:1; /* Locks streams */
354 int radio; 344 int radio;
355 345
356 struct videobuf_queue vb_vidq; 346 struct videobuf_queue vb_vidq;
357 347
358 enum v4l2_buf_type type; 348 enum v4l2_buf_type type;
359}; 349};
360 350
361/**********************************************************************************/ 351/**********************************************************************************/
362/* set/get i2c */ 352/* set/get i2c */
363#define I2C_SPEED_1M 0x0 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ 353#define I2C_SPEED_1M 0x0 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */
364#define I2C_SPEED_400K 0x1 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ 354#define I2C_SPEED_400K 0x1 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */
365#define I2C_SPEED_100K 0x2 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ 355#define I2C_SPEED_100K 0x2 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */
366#define I2C_SPEED_5M 0x3 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ 356#define I2C_SPEED_5M 0x3 /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */
367 357
368#define I2C_STOP 0x0 /* 0-- STOP transaction */ 358#define I2C_STOP 0x0 /* 0-- STOP transaction */
369#define I2C_NOSTOP 0x1 /* 1-- do not transmit STOP at end of transaction */ 359#define I2C_NOSTOP 0x1 /* 1-- do not transmit STOP at end of transaction */
370#define I2C_SYNC 0x1 /* 1--alllow slave to insert clock wait states */ 360#define I2C_SYNC 0x1 /* 1--alllow slave to insert clock wait states */
371 361
372struct cx231xx_i2c { 362struct cx231xx_i2c {
373 struct cx231xx *dev; 363 struct cx231xx *dev;
374 364
375 int nr; 365 int nr;
376 366
377 /* i2c i/o */ 367 /* i2c i/o */
378 struct i2c_adapter i2c_adap; 368 struct i2c_adapter i2c_adap;
379 struct i2c_algo_bit_data i2c_algo; 369 struct i2c_algo_bit_data i2c_algo;
380 struct i2c_client i2c_client; 370 struct i2c_client i2c_client;
381 u32 i2c_rc; 371 u32 i2c_rc;
382 372
383 /* different settings for each bus */ 373 /* different settings for each bus */
384 u8 i2c_period; 374 u8 i2c_period;
385 u8 i2c_nostop; 375 u8 i2c_nostop;
386 u8 i2c_reserve; 376 u8 i2c_reserve;
387}; 377};
388 378
389struct cx231xx_i2c_xfer_data{ 379struct cx231xx_i2c_xfer_data {
390 u8 dev_addr; 380 u8 dev_addr;
391 u8 direction; /* 1 - IN, 0 - OUT */ 381 u8 direction; /* 1 - IN, 0 - OUT */
392 u8 saddr_len; /* sub address len */ 382 u8 saddr_len; /* sub address len */
393 u16 saddr_dat; /* sub addr data */ 383 u16 saddr_dat; /* sub addr data */
394 u8 buf_size; /* buffer size */ 384 u8 buf_size; /* buffer size */
395 u8* p_buffer; /* pointer to the buffer */ 385 u8 *p_buffer; /* pointer to the buffer */
396}; 386};
397 387
398typedef struct _VENDOR_REQUEST_IN 388typedef struct _VENDOR_REQUEST_IN {
399{ 389 u8 bRequest;
400 u8 bRequest; 390 u16 wValue;
401 u16 wValue; 391 u16 wIndex;
402 u16 wIndex; 392 u16 wLength;
403 u16 wLength; 393 u8 direction;
404 u8 direction; 394 u8 bData;
405 u8 bData; 395 u8 *pBuff;
406 u8 *pBuff;
407} VENDOR_REQUEST_IN, *PVENDOR_REQUEST_IN; 396} VENDOR_REQUEST_IN, *PVENDOR_REQUEST_IN;
408 397
409struct cx231xx_ctrl { 398struct cx231xx_ctrl {
410 struct v4l2_queryctrl v; 399 struct v4l2_queryctrl v;
411 u32 off; 400 u32 off;
412 u32 reg; 401 u32 reg;
413 u32 mask; 402 u32 mask;
414 u32 shift; 403 u32 shift;
415}; 404};
416 405
417typedef enum{ 406typedef enum {
418 Raw_Video = 0, 407 Raw_Video = 0,
419 Audio, 408 Audio,
420 Vbi, /* VANC */ 409 Vbi, /* VANC */
421 Sliced_cc, /* HANC */ 410 Sliced_cc, /* HANC */
422 TS1_serial_mode, 411 TS1_serial_mode,
423 TS2, 412 TS2,
424 TS1_parallel_mode 413 TS1_parallel_mode
425}TRANSFER_TYPE; 414} TRANSFER_TYPE;
426 415
427struct cx231xx_video_mode { 416struct cx231xx_video_mode {
428 /* Isoc control struct */ 417 /* Isoc control struct */
429 struct cx231xx_dmaqueue vidq; 418 struct cx231xx_dmaqueue vidq;
430 struct cx231xx_usb_isoc_ctl isoc_ctl; 419 struct cx231xx_usb_isoc_ctl isoc_ctl;
431 spinlock_t slock; 420 spinlock_t slock;
432 421
433 /* usb transfer */ 422 /* usb transfer */
434 int alt; /* alternate */ 423 int alt; /* alternate */
435 int max_pkt_size; /* max packet size of isoc transaction */ 424 int max_pkt_size; /* max packet size of isoc transaction */
436 int num_alt; /* Number of alternative settings */ 425 int num_alt; /* Number of alternative settings */
437 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ 426 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
438 u16 end_point_addr; 427 u16 end_point_addr;
439}; 428};
440 429
441
442/* main device struct */ 430/* main device struct */
443struct cx231xx { 431struct cx231xx {
444 /* generic device properties */ 432 /* generic device properties */
445 char name[30]; /* name (including minor) of the device */ 433 char name[30]; /* name (including minor) of the device */
446 int model; /* index in the device_data struct */ 434 int model; /* index in the device_data struct */
447 int devno; /* marks the number of this device */ 435 int devno; /* marks the number of this device */
448 436
449 struct cx231xx_board board; 437 struct cx231xx_board board;
450 438
451 unsigned int stream_on:1; /* Locks streams */ 439 unsigned int stream_on:1; /* Locks streams */
452 unsigned int vbi_stream_on:1; /* Locks streams for VBI */ 440 unsigned int vbi_stream_on:1; /* Locks streams for VBI */
453 unsigned int has_audio_class:1; 441 unsigned int has_audio_class:1;
454 unsigned int has_alsa_audio:1; 442 unsigned int has_alsa_audio:1;
455 443
456 struct cx231xx_fmt *format; 444 struct cx231xx_fmt *format;
457 445
458 struct cx231xx_IR *ir; 446 struct cx231xx_IR *ir;
459 447
460 struct list_head devlist; 448 struct list_head devlist;
461 449
462 int tuner_type; /* type of the tuner */ 450 int tuner_type; /* type of the tuner */
463 int tuner_addr; /* tuner address */ 451 int tuner_addr; /* tuner address */
464 452
465 /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ 453 /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
466 struct cx231xx_i2c i2c_bus[3]; 454 struct cx231xx_i2c i2c_bus[3];
467 unsigned int xc_fw_load_done:1; 455 unsigned int xc_fw_load_done:1;
468 struct mutex gpio_i2c_lock; 456 struct mutex gpio_i2c_lock;
469 457
470 /* video for linux */ 458 /* video for linux */
471 int users; /* user count for exclusive use */ 459 int users; /* user count for exclusive use */
472 struct video_device *vdev; /* video for linux device struct */ 460 struct video_device *vdev; /* video for linux device struct */
473 v4l2_std_id norm; /* selected tv norm */ 461 v4l2_std_id norm; /* selected tv norm */
474 int ctl_freq; /* selected frequency */ 462 int ctl_freq; /* selected frequency */
475 unsigned int ctl_ainput; /* selected audio input */ 463 unsigned int ctl_ainput; /* selected audio input */
476 int mute; 464 int mute;
477 int volume; 465 int volume;
478 466
479 /* frame properties */ 467 /* frame properties */
480 int width; /* current frame width */ 468 int width; /* current frame width */
481 int height; /* current frame height */ 469 int height; /* current frame height */
482 unsigned hscale; /* horizontal scale factor (see datasheet) */ 470 unsigned hscale; /* horizontal scale factor (see datasheet) */
483 unsigned vscale; /* vertical scale factor (see datasheet) */ 471 unsigned vscale; /* vertical scale factor (see datasheet) */
484 int interlaced; /* 1=interlace fileds, 0=just top fileds */ 472 int interlaced; /* 1=interlace fileds, 0=just top fileds */
485 473
486 struct cx231xx_audio adev; 474 struct cx231xx_audio adev;
487 475
488 /* states */ 476 /* states */
489 enum cx231xx_dev_state state; 477 enum cx231xx_dev_state state;
490 478
491 struct work_struct request_module_wk; 479 struct work_struct request_module_wk;
492 480
493 /* locks */ 481 /* locks */
494 struct mutex lock; 482 struct mutex lock;
495 struct mutex ctrl_urb_lock; /* protects urb_buf */ 483 struct mutex ctrl_urb_lock; /* protects urb_buf */
496 struct list_head inqueue, outqueue; 484 struct list_head inqueue, outqueue;
497 wait_queue_head_t open, wait_frame, wait_stream; 485 wait_queue_head_t open, wait_frame, wait_stream;
498 struct video_device *vbi_dev; 486 struct video_device *vbi_dev;
@@ -500,54 +488,56 @@ struct cx231xx {
500 488
501 unsigned char eedata[256]; 489 unsigned char eedata[256];
502 490
503 struct cx231xx_video_mode video_mode; 491 struct cx231xx_video_mode video_mode;
504 struct cx231xx_video_mode vbi_mode; 492 struct cx231xx_video_mode vbi_mode;
505 struct cx231xx_video_mode sliced_cc_mode; 493 struct cx231xx_video_mode sliced_cc_mode;
506 struct cx231xx_video_mode ts1_mode; 494 struct cx231xx_video_mode ts1_mode;
507
508 struct usb_device *udev; /* the usb device */
509 char urb_buf[URB_MAX_CTRL_SIZE];/* urb control msg buffer */
510 495
496 struct usb_device *udev; /* the usb device */
497 char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
511 498
512 /* helper funcs that call usb_control_msg */ 499 /* helper funcs that call usb_control_msg */
513 int (*cx231xx_read_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, 500 int (*cx231xx_read_ctrl_reg) (struct cx231xx * dev, u8 req, u16 reg,
514 char *buf, int len);
515 int (*cx231xx_write_ctrl_reg)(struct cx231xx *dev, u8 req, u16 reg,
516 char *buf, int len); 501 char *buf, int len);
517 int (*cx231xx_send_usb_command)(struct cx231xx_i2c *i2c_bus, 502 int (*cx231xx_write_ctrl_reg) (struct cx231xx * dev, u8 req, u16 reg,
518 struct cx231xx_i2c_xfer_data *req_data); 503 char *buf, int len);
519 int (*cx231xx_gpio_i2c_read)(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); 504 int (*cx231xx_send_usb_command) (struct cx231xx_i2c * i2c_bus,
520 int (*cx231xx_gpio_i2c_write)(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); 505 struct cx231xx_i2c_xfer_data *
521 506 req_data);
522 int (*cx231xx_set_analog_freq)(struct cx231xx *dev, u32 freq ) ; 507 int (*cx231xx_gpio_i2c_read) (struct cx231xx * dev, u8 dev_addr,
523 int (*cx231xx_reset_analog_tuner)(struct cx231xx *dev) ; 508 u8 * buf, u8 len);
509 int (*cx231xx_gpio_i2c_write) (struct cx231xx * dev, u8 dev_addr,
510 u8 * buf, u8 len);
511
512 int (*cx231xx_set_analog_freq) (struct cx231xx * dev, u32 freq);
513 int (*cx231xx_reset_analog_tuner) (struct cx231xx * dev);
524 514
525 enum cx231xx_mode mode; 515 enum cx231xx_mode mode;
526 516
527 struct cx231xx_dvb *dvb; 517 struct cx231xx_dvb *dvb;
528 518
529 /* Cx231xx supported PCB config's */ 519 /* Cx231xx supported PCB config's */
530 struct pcb_config current_pcb_config; 520 struct pcb_config current_pcb_config;
531 u8 current_scenario_idx; 521 u8 current_scenario_idx;
532 u8 interface_count; 522 u8 interface_count;
533 u8 max_iad_interface_count; 523 u8 max_iad_interface_count;
534 524
535 /* GPIO related register direction and values */ 525 /* GPIO related register direction and values */
536 u32 gpio_dir; 526 u32 gpio_dir;
537 u32 gpio_val; 527 u32 gpio_val;
538 528
539 /* Power Modes */ 529 /* Power Modes */
540 int power_mode; 530 int power_mode;
541 531
542 /* colibri parameters */ 532 /* colibri parameters */
543 enum AFE_MODE colibri_mode; 533 enum AFE_MODE colibri_mode;
544 u32 colibri_ref_count; 534 u32 colibri_ref_count;
545 535
546 /* video related parameters */ 536 /* video related parameters */
547 u32 video_input; 537 u32 video_input;
548 u32 active_mode; 538 u32 active_mode;
549 u8 vbi_or_sliced_cc_mode; /* 0 - vbi ; 1 - sliced cc mode */ 539 u8 vbi_or_sliced_cc_mode; /* 0 - vbi ; 1 - sliced cc mode */
550 enum cx231xx_std_mode std_mode; /* 0 - Air; 1 - cable */ 540 enum cx231xx_std_mode std_mode; /* 0 - Air; 1 - cable */
551 541
552}; 542};
553 543
@@ -555,29 +545,31 @@ struct cx231xx_ops {
555 struct list_head next; 545 struct list_head next;
556 char *name; 546 char *name;
557 int id; 547 int id;
558 int (*init)(struct cx231xx *); 548 int (*init) (struct cx231xx *);
559 int (*fini)(struct cx231xx *); 549 int (*fini) (struct cx231xx *);
560}; 550};
561 551
562/* call back functions in dvb module */ 552/* call back functions in dvb module */
563int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq ) ; 553int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq);
564int cx231xx_reset_analog_tuner(struct cx231xx *dev) ; 554int cx231xx_reset_analog_tuner(struct cx231xx *dev);
565 555
566/* Provided by cx231xx-i2c.c */ 556/* Provided by cx231xx-i2c.c */
567void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd, void *arg); 557void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
558 void *arg);
568void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c); 559void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c);
569int cx231xx_i2c_register(struct cx231xx_i2c *bus); 560int cx231xx_i2c_register(struct cx231xx_i2c *bus);
570int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); 561int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
571 562
572/* Internal block control functions */ 563/* Internal block control functions */
573int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, 564int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr,
574 u16 saddr, u8 saddr_len, u32 *data, u8 data_len); 565 u16 saddr, u8 saddr_len, u32 * data, u8 data_len);
575int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, 566int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr,
576 u16 saddr, u8 saddr_len, u32 data, u8 data_len); 567 u16 saddr, u8 saddr_len, u32 data, u8 data_len);
577int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, u16 register_address, 568int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size,
578 u8 bit_start,u8 bit_end, u32 value); 569 u16 register_address, u8 bit_start, u8 bit_end,
570 u32 value);
579int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, 571int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr,
580 u16 saddr, u32 mask, u32 value); 572 u16 saddr, u32 mask, u32 value);
581u32 cx231xx_set_field(u32 field_mask, u32 data); 573u32 cx231xx_set_field(u32 field_mask, u32 data);
582 574
583/* Colibri related functions */ 575/* Colibri related functions */
@@ -596,23 +588,26 @@ int cx231xx_flatiron_set_audio_input(struct cx231xx *dev, u8 audio_input);
596 588
597/* DIF related functions */ 589/* DIF related functions */
598int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, 590int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode,
599 u32 function_mode, u32 standard); 591 u32 function_mode, u32 standard);
600int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard); 592int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard);
601int cx231xx_tuner_pre_channel_change(struct cx231xx *dev); 593int cx231xx_tuner_pre_channel_change(struct cx231xx *dev);
602int cx231xx_tuner_post_channel_change(struct cx231xx *dev); 594int cx231xx_tuner_post_channel_change(struct cx231xx *dev);
603 595
604/* video parser functions */ 596/* video parser functions */
605u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used); 597u8 cx231xx_find_next_SAV_EAV(u8 * p_buffer, u32 buffer_size,
606u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, u32 *p_bytes_used); 598 u32 * p_bytes_used);
599u8 cx231xx_find_boundary_SAV_EAV(u8 * p_buffer, u8 * partial_buf,
600 u32 * p_bytes_used);
607int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 601int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
608 u8 *p_buffer, u32 bytes_to_copy); 602 u8 * p_buffer, u32 bytes_to_copy);
609void cx231xx_reset_video_buffer(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q); 603void cx231xx_reset_video_buffer(struct cx231xx *dev,
610u8 cx231xx_is_buffer_done(struct cx231xx *dev,struct cx231xx_dmaqueue *dma_q); 604 struct cx231xx_dmaqueue *dma_q);
611u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 605u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q);
612 u8 *p_line, u32 length, int field_number); 606u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
613u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, 607 u8 * p_line, u32 length, int field_number);
614 u8 sav_eav, u8 *p_buffer, u32 buffer_size); 608u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
615void cx231xx_swab(u16 *from, u16 *to, u16 len); 609 u8 sav_eav, u8 * p_buffer, u32 buffer_size);
610void cx231xx_swab(u16 * from, u16 * to, u16 len);
616 611
617/* Provided by cx231xx-core.c */ 612/* Provided by cx231xx-core.c */
618 613
@@ -622,46 +617,49 @@ void cx231xx_release_buffers(struct cx231xx *dev);
622 617
623/* read from control pipe */ 618/* read from control pipe */
624int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, 619int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
625 char *buf, int len); 620 char *buf, int len);
626 621
627/* write to control pipe */ 622/* write to control pipe */
628int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, 623int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
629 char *buf, int len); 624 char *buf, int len);
630int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode); 625int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode);
631 626
632int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN *ven_req); 627int cx231xx_send_vendor_cmd(struct cx231xx *dev, VENDOR_REQUEST_IN * ven_req);
633int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, 628int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus,
634 struct cx231xx_i2c_xfer_data *req_data); 629 struct cx231xx_i2c_xfer_data *req_data);
635 630
636/* Gpio related functions */ 631/* Gpio related functions */
637int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val, 632int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val,
638 u8 len, u8 request, u8 direction); 633 u8 len, u8 request, u8 direction);
639int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val); 634int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val);
640int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8* gpio_val); 635int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 * gpio_val);
641int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value); 636int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value);
642int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number, int pin_value); 637int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number,
638 int pin_value);
643 639
644int cx231xx_gpio_i2c_start(struct cx231xx *dev); 640int cx231xx_gpio_i2c_start(struct cx231xx *dev);
645int cx231xx_gpio_i2c_end(struct cx231xx *dev); 641int cx231xx_gpio_i2c_end(struct cx231xx *dev);
646int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data); 642int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data);
647int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf); 643int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 * buf);
648int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev); 644int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev);
649int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev); 645int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev);
650int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev); 646int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev);
651 647
652int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); 648int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len);
653int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf ,u8 len); 649int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 * buf, u8 len);
654 650
655/* audio related functions */ 651/* audio related functions */
656int cx231xx_set_audio_decoder_input(struct cx231xx *dev, enum AUDIO_INPUT audio_input); 652int cx231xx_set_audio_decoder_input(struct cx231xx *dev,
653 enum AUDIO_INPUT audio_input);
657 654
658int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type); 655int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type);
659int cx231xx_resolution_set(struct cx231xx *dev); 656int cx231xx_resolution_set(struct cx231xx *dev);
660int cx231xx_set_video_alternate(struct cx231xx *dev); 657int cx231xx_set_video_alternate(struct cx231xx *dev);
661int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt); 658int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt);
662int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, 659int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
663 int num_bufs, int max_pkt_size, 660 int num_bufs, int max_pkt_size,
664 int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)); 661 int (*isoc_copy) (struct cx231xx * dev,
662 struct urb * urb));
665void cx231xx_uninit_isoc(struct cx231xx *dev); 663void cx231xx_uninit_isoc(struct cx231xx *dev);
666int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode); 664int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode);
667int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio); 665int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio);
@@ -673,7 +671,7 @@ int cx231xx_register_analog_devices(struct cx231xx *dev);
673void cx231xx_remove_from_devlist(struct cx231xx *dev); 671void cx231xx_remove_from_devlist(struct cx231xx *dev);
674void cx231xx_add_into_devlist(struct cx231xx *dev); 672void cx231xx_add_into_devlist(struct cx231xx *dev);
675struct cx231xx *cx231xx_get_device(int minor, 673struct cx231xx *cx231xx_get_device(int minor,
676 enum v4l2_buf_type *fh_type, int *has_radio); 674 enum v4l2_buf_type *fh_type, int *has_radio);
677void cx231xx_init_extension(struct cx231xx *dev); 675void cx231xx_init_extension(struct cx231xx *dev);
678void cx231xx_close_extension(struct cx231xx *dev); 676void cx231xx_close_extension(struct cx231xx *dev);
679 677
@@ -695,7 +693,8 @@ int cx231xx_power_suspend(struct cx231xx *dev);
695 693
696/* chip specific control functions */ 694/* chip specific control functions */
697int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); 695int cx231xx_init_ctrl_pin_status(struct cx231xx *dev);
698int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, u8 analog_or_digital); 696int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev,
697 u8 analog_or_digital);
699int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex); 698int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex);
700 699
701/* video audio decoder related functions */ 700/* video audio decoder related functions */
@@ -705,8 +704,8 @@ int cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input);
705int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev); 704int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev);
706int cx231xx_set_audio_input(struct cx231xx *dev, u8 input); 705int cx231xx_set_audio_input(struct cx231xx *dev, u8 input);
707void get_scale(struct cx231xx *dev, 706void get_scale(struct cx231xx *dev,
708 unsigned int width, unsigned int height, 707 unsigned int width, unsigned int height,
709 unsigned int *hscale, unsigned int *vscale); 708 unsigned int *hscale, unsigned int *vscale);
710 709
711/* Provided by cx231xx-video.c */ 710/* Provided by cx231xx-video.c */
712int cx231xx_register_extension(struct cx231xx_ops *dev); 711int cx231xx_register_extension(struct cx231xx_ops *dev);
@@ -743,7 +742,6 @@ int cx231xx_ir_fini(struct cx231xx *dev);
743 printk(KERN_WARNING "%s: "fmt,\ 742 printk(KERN_WARNING "%s: "fmt,\
744 dev->name , ##arg); } while (0) 743 dev->name , ##arg); } while (0)
745 744
746
747static inline unsigned int norm_maxw(struct cx231xx *dev) 745static inline unsigned int norm_maxw(struct cx231xx *dev)
748{ 746{
749 if (dev->board.max_range_640_480) 747 if (dev->board.max_range_640_480)