]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/media/video/cx231xx/cx231xx.h
V4L/DVB (10957): cx231xx: Fix CodingStyle
[mirror_ubuntu-bionic-kernel.git] / drivers / media / video / cx231xx / cx231xx.h
CommitLineData
e0d3bafd
SD
1/*
2 cx231xx.h - driver for Conexant Cx23100/101/102 USB video capture devices
3
4 Copyright (C) 2008 <srinivasa.deevi at conexant dot com>
84b5dbf3 5 Based on em28xx driver
e0d3bafd
SD
6
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
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#ifndef _CX231XX_H
23#define _CX231XX_H
24
25#include <linux/videodev2.h>
26#include <media/videobuf-vmalloc.h>
27
28#include <linux/i2c.h>
29#include <linux/i2c-algo-bit.h>
30#include <linux/mutex.h>
31#include <media/ir-kbd-i2c.h>
b9255176
SD
32#if defined(CONFIG_VIDEO_CX231XX_DVB) || \
33 defined(CONFIG_VIDEO_CX231XX_DVB_MODULE)
e0d3bafd
SD
34#include <media/videobuf-dvb.h>
35#endif
36
37#include "cx231xx-reg.h"
38#include "cx231xx-pcb-config.h"
39#include "cx231xx-conf-reg.h"
40
e0d3bafd
SD
41#define DRIVER_NAME "cx231xx"
42#define PWR_SLEEP_INTERVAL 5
43
44/* I2C addresses for control block in Cx231xx */
45#define Colibri_DEVICE_ADDRESS 0x60
46#define Flatrion_DEVICE_ADDRESS 0x98
47#define HAMMERHEAD_I2C_ADDRESS 0x88
48#define DIF_USE_BASEBAND 0xFFFFFFFF
49
50/* Boards supported by driver */
51#define CX231XX_BOARD_UNKNOWN 0
52#define CX231XX_BOARD_CNXT_RDE_250 1
53#define CX231XX_BOARD_CNXT_RDU_250 2
54
55/* Limits minimum and default number of buffers */
56#define CX231XX_MIN_BUF 4
57#define CX231XX_DEF_BUF 12
58#define CX231XX_DEF_VBI_BUF 6
59
60#define VBI_LINE_COUNT 17
61#define VBI_LINE_LENGTH 1440
62
63/*Limits the max URB message size */
64#define URB_MAX_CTRL_SIZE 80
65
66/* Params for validated field */
67#define CX231XX_BOARD_NOT_VALIDATED 1
84b5dbf3 68#define CX231XX_BOARD_VALIDATED 0
e0d3bafd
SD
69
70/* maximum number of cx231xx boards */
71#define CX231XX_MAXBOARDS 8
72
73/* maximum number of frames that can be queued */
74#define CX231XX_NUM_FRAMES 5
75
76/* number of buffers for isoc transfers */
77#define CX231XX_NUM_BUFS 8
78
79/* number of packets for each buffer
80 windows requests only 40 packets .. so we better do the same
81 this is what I found out for all alternate numbers there!
82 */
83#define CX231XX_NUM_PACKETS 40
84
e0d3bafd
SD
85/* default alternate; 0 means choose the best */
86#define CX231XX_PINOUT 0
87
88#define CX231XX_INTERLACED_DEFAULT 1
89
e0d3bafd 90/* time to wait when stopping the isoc transfer */
b9255176
SD
91#define CX231XX_URB_TIMEOUT \
92 msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS)
e0d3bafd 93
e0d3bafd
SD
94enum cx231xx_mode {
95 CX231XX_SUSPEND,
96 CX231XX_ANALOG_MODE,
97 CX231XX_DIGITAL_MODE,
98};
99
100enum cx231xx_std_mode {
101 CX231XX_TV_AIR = 0,
102 CX231XX_TV_CABLE
103};
104
105enum cx231xx_stream_state {
106 STREAM_OFF,
107 STREAM_INTERRUPT,
108 STREAM_ON,
109};
110
111struct cx231xx;
112
113struct cx231xx_usb_isoc_ctl {
84b5dbf3
MCC
114 /* max packet size of isoc transaction */
115 int max_pkt_size;
e0d3bafd 116
84b5dbf3
MCC
117 /* number of allocated urbs */
118 int num_bufs;
e0d3bafd 119
84b5dbf3
MCC
120 /* urb for isoc transfers */
121 struct urb **urb;
e0d3bafd 122
84b5dbf3
MCC
123 /* transfer buffers for isoc transfer */
124 char **transfer_buffer;
e0d3bafd 125
84b5dbf3
MCC
126 /* Last buffer command and region */
127 u8 cmd;
128 int pos, size, pktsize;
e0d3bafd 129
84b5dbf3
MCC
130 /* Last field: ODD or EVEN? */
131 int field;
e0d3bafd 132
84b5dbf3
MCC
133 /* Stores incomplete commands */
134 u32 tmp_buf;
135 int tmp_buf_len;
e0d3bafd 136
84b5dbf3
MCC
137 /* Stores already requested buffers */
138 struct cx231xx_buffer *buf;
e0d3bafd 139
84b5dbf3
MCC
140 /* Stores the number of received fields */
141 int nfields;
e0d3bafd 142
84b5dbf3 143 /* isoc urb callback */
cde4362f 144 int (*isoc_copy) (struct cx231xx *dev, struct urb *urb);
e0d3bafd
SD
145};
146
e0d3bafd 147struct cx231xx_fmt {
84b5dbf3
MCC
148 char *name;
149 u32 fourcc; /* v4l2 format id */
150 int depth;
151 int reg;
e0d3bafd
SD
152};
153
154/* buffer for one video frame */
155struct cx231xx_buffer {
156 /* common v4l buffer stuff -- must be first */
157 struct videobuf_buffer vb;
158
159 struct list_head frame;
160 int top_field;
161 int receiving;
162};
163
164struct cx231xx_dmaqueue {
84b5dbf3
MCC
165 struct list_head active;
166 struct list_head queued;
e0d3bafd 167
84b5dbf3 168 wait_queue_head_t wq;
e0d3bafd
SD
169
170 /* Counters to control buffer fill */
84b5dbf3
MCC
171 int pos;
172 u8 is_partial_line;
173 u8 partial_buf[8];
174 u8 last_sav;
175 int current_field;
176 u32 bytes_left_in_line;
177 u32 lines_completed;
178 u8 field1_done;
179 u32 lines_per_field;
e0d3bafd
SD
180};
181
e0d3bafd
SD
182/* inputs */
183
184#define MAX_CX231XX_INPUT 4
185
186enum cx231xx_itype {
187 CX231XX_VMUX_COMPOSITE1 = 1,
188 CX231XX_VMUX_SVIDEO,
189 CX231XX_VMUX_TELEVISION,
84b5dbf3
MCC
190 CX231XX_VMUX_CABLE,
191 CX231XX_RADIO,
192 CX231XX_VMUX_DVB,
e0d3bafd
SD
193 CX231XX_VMUX_DEBUG
194};
195
196enum cx231xx_v_input {
84b5dbf3
MCC
197 CX231XX_VIN_1_1 = 0x1,
198 CX231XX_VIN_2_1,
199 CX231XX_VIN_3_1,
200 CX231XX_VIN_4_1,
201 CX231XX_VIN_1_2 = 0x01,
202 CX231XX_VIN_2_2,
203 CX231XX_VIN_3_2,
204 CX231XX_VIN_1_3 = 0x1,
205 CX231XX_VIN_2_3,
206 CX231XX_VIN_3_3,
e0d3bafd
SD
207};
208
209/* cx231xx has two audio inputs: tuner and line in */
210enum cx231xx_amux {
211 /* This is the only entry for cx231xx tuner input */
84b5dbf3 212 CX231XX_AMUX_VIDEO, /* cx231xx tuner */
e0d3bafd
SD
213 CX231XX_AMUX_LINE_IN, /* Line In */
214};
215
216struct cx231xx_reg_seq {
217 unsigned char bit;
84b5dbf3 218 unsigned char val;
e0d3bafd
SD
219 int sleep;
220};
221
222struct cx231xx_input {
223 enum cx231xx_itype type;
224 unsigned int vmux;
225 enum cx231xx_amux amux;
226 struct cx231xx_reg_seq *gpio;
227};
228
229#define INPUT(nr) (&cx231xx_boards[dev->model].input[nr])
230
231enum cx231xx_decoder {
232 CX231XX_NODECODER,
233 CX231XX_AVDECODER
234};
235
b9255176 236enum CX231XX_I2C_MASTER_PORT {
84b5dbf3
MCC
237 I2C_0 = 0,
238 I2C_1 = 1,
239 I2C_2 = 2,
240 I2C_3 = 3
b9255176 241};
e0d3bafd
SD
242
243struct cx231xx_board {
244 char *name;
245 int vchannels;
246 int tuner_type;
247 int tuner_addr;
84b5dbf3 248 v4l2_std_id norm; /* tv norm */
e0d3bafd 249
84b5dbf3
MCC
250 /* demod related */
251 int demod_addr;
252 u8 demod_xfer_mode; /* 0 - Serial; 1 - parallel */
e0d3bafd
SD
253
254 /* GPIO Pins */
255 struct cx231xx_reg_seq *dvb_gpio;
256 struct cx231xx_reg_seq *suspend_gpio;
257 struct cx231xx_reg_seq *tuner_gpio;
84b5dbf3
MCC
258 u8 tuner_sif_gpio;
259 u8 tuner_scl_gpio;
260 u8 tuner_sda_gpio;
e0d3bafd 261
84b5dbf3
MCC
262 /* PIN ctrl */
263 u32 ctl_pin_status_mask;
264 u8 agc_analog_digital_select_gpio;
265 u32 gpio_pin_status_mask;
e0d3bafd 266
84b5dbf3
MCC
267 /* i2c masters */
268 u8 tuner_i2c_master;
269 u8 demod_i2c_master;
e0d3bafd
SD
270
271 unsigned int max_range_640_480:1;
272 unsigned int has_dvb:1;
273 unsigned int valid:1;
274
275 unsigned char xclk, i2c_speed;
276
277 enum cx231xx_decoder decoder;
278
84b5dbf3
MCC
279 struct cx231xx_input input[MAX_CX231XX_INPUT];
280 struct cx231xx_input radio;
281 IR_KEYTAB_TYPE *ir_codes;
e0d3bafd
SD
282};
283
284/* device states */
285enum cx231xx_dev_state {
286 DEV_INITIALIZED = 0x01,
287 DEV_DISCONNECTED = 0x02,
288 DEV_MISCONFIGURED = 0x04,
289};
290
84b5dbf3
MCC
291enum AFE_MODE {
292 AFE_MODE_LOW_IF,
293 AFE_MODE_BASEBAND,
294 AFE_MODE_EU_HI_IF,
295 AFE_MODE_US_HI_IF,
296 AFE_MODE_JAPAN_HI_IF
e0d3bafd
SD
297};
298
84b5dbf3
MCC
299enum AUDIO_INPUT {
300 AUDIO_INPUT_MUTE,
301 AUDIO_INPUT_LINE,
302 AUDIO_INPUT_TUNER_TV,
303 AUDIO_INPUT_SPDIF,
304 AUDIO_INPUT_TUNER_FM
e0d3bafd
SD
305};
306
307#define CX231XX_AUDIO_BUFS 5
308#define CX231XX_NUM_AUDIO_PACKETS 64
309#define CX231XX_CAPTURE_STREAM_EN 1
310#define CX231XX_STOP_AUDIO 0
311#define CX231XX_START_AUDIO 1
312
e0d3bafd
SD
313/* cx231xx extensions */
314#define CX231XX_AUDIO 0x10
315#define CX231XX_DVB 0x20
316
317struct cx231xx_audio {
318 char name[50];
319 char *transfer_buffer[CX231XX_AUDIO_BUFS];
320 struct urb *urb[CX231XX_AUDIO_BUFS];
321 struct usb_device *udev;
322 unsigned int capture_transfer_done;
84b5dbf3 323 struct snd_pcm_substream *capture_pcm_substream;
e0d3bafd
SD
324
325 unsigned int hwptr_done_capture;
84b5dbf3 326 struct snd_card *sndcard;
e0d3bafd
SD
327
328 int users, shutdown;
329 enum cx231xx_stream_state capture_stream;
330 spinlock_t slock;
331
84b5dbf3
MCC
332 int alt; /* alternate */
333 int max_pkt_size; /* max packet size of isoc transaction */
334 int num_alt; /* Number of alternative settings */
e0d3bafd 335 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
84b5dbf3 336 u16 end_point_addr;
e0d3bafd
SD
337};
338
339struct cx231xx;
340
341struct cx231xx_fh {
342 struct cx231xx *dev;
84b5dbf3
MCC
343 unsigned int stream_on:1; /* Locks streams */
344 int radio;
e0d3bafd 345
84b5dbf3 346 struct videobuf_queue vb_vidq;
e0d3bafd 347
84b5dbf3 348 enum v4l2_buf_type type;
e0d3bafd
SD
349};
350
b9255176 351/*****************************************************************/
e0d3bafd 352/* set/get i2c */
b9255176
SD
353/* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */
354#define I2C_SPEED_1M 0x0
355#define I2C_SPEED_400K 0x1
356#define I2C_SPEED_100K 0x2
357#define I2C_SPEED_5M 0x3
358
359/* 0-- STOP transaction */
360#define I2C_STOP 0x0
361/* 1-- do not transmit STOP at end of transaction */
362#define I2C_NOSTOP 0x1
363/* 1--alllow slave to insert clock wait states */
364#define I2C_SYNC 0x1
e0d3bafd
SD
365
366struct cx231xx_i2c {
84b5dbf3 367 struct cx231xx *dev;
e0d3bafd 368
84b5dbf3 369 int nr;
e0d3bafd
SD
370
371 /* i2c i/o */
84b5dbf3
MCC
372 struct i2c_adapter i2c_adap;
373 struct i2c_algo_bit_data i2c_algo;
374 struct i2c_client i2c_client;
375 u32 i2c_rc;
e0d3bafd
SD
376
377 /* different settings for each bus */
84b5dbf3
MCC
378 u8 i2c_period;
379 u8 i2c_nostop;
380 u8 i2c_reserve;
e0d3bafd
SD
381};
382
84b5dbf3
MCC
383struct cx231xx_i2c_xfer_data {
384 u8 dev_addr;
385 u8 direction; /* 1 - IN, 0 - OUT */
386 u8 saddr_len; /* sub address len */
387 u16 saddr_dat; /* sub addr data */
388 u8 buf_size; /* buffer size */
389 u8 *p_buffer; /* pointer to the buffer */
e0d3bafd
SD
390};
391
b9255176 392struct VENDOR_REQUEST_IN{
84b5dbf3
MCC
393 u8 bRequest;
394 u16 wValue;
395 u16 wIndex;
396 u16 wLength;
397 u8 direction;
398 u8 bData;
399 u8 *pBuff;
b9255176 400};
e0d3bafd
SD
401
402struct cx231xx_ctrl {
403 struct v4l2_queryctrl v;
84b5dbf3
MCC
404 u32 off;
405 u32 reg;
406 u32 mask;
407 u32 shift;
e0d3bafd
SD
408};
409
b9255176 410enum TRANSFER_TYPE{
84b5dbf3
MCC
411 Raw_Video = 0,
412 Audio,
413 Vbi, /* VANC */
414 Sliced_cc, /* HANC */
415 TS1_serial_mode,
416 TS2,
417 TS1_parallel_mode
b9255176 418} ;
e0d3bafd
SD
419
420struct cx231xx_video_mode {
84b5dbf3 421 /* Isoc control struct */
e0d3bafd
SD
422 struct cx231xx_dmaqueue vidq;
423 struct cx231xx_usb_isoc_ctl isoc_ctl;
424 spinlock_t slock;
425
426 /* usb transfer */
84b5dbf3
MCC
427 int alt; /* alternate */
428 int max_pkt_size; /* max packet size of isoc transaction */
429 int num_alt; /* Number of alternative settings */
e0d3bafd 430 unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */
84b5dbf3 431 u16 end_point_addr;
e0d3bafd
SD
432};
433
e0d3bafd
SD
434/* main device struct */
435struct cx231xx {
436 /* generic device properties */
84b5dbf3
MCC
437 char name[30]; /* name (including minor) of the device */
438 int model; /* index in the device_data struct */
439 int devno; /* marks the number of this device */
e0d3bafd
SD
440
441 struct cx231xx_board board;
442
84b5dbf3
MCC
443 unsigned int stream_on:1; /* Locks streams */
444 unsigned int vbi_stream_on:1; /* Locks streams for VBI */
e0d3bafd
SD
445 unsigned int has_audio_class:1;
446 unsigned int has_alsa_audio:1;
447
84b5dbf3 448 struct cx231xx_fmt *format;
e0d3bafd
SD
449
450 struct cx231xx_IR *ir;
451
84b5dbf3 452 struct list_head devlist;
e0d3bafd 453
84b5dbf3
MCC
454 int tuner_type; /* type of the tuner */
455 int tuner_addr; /* tuner address */
e0d3bafd 456
84b5dbf3
MCC
457 /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
458 struct cx231xx_i2c i2c_bus[3];
459 unsigned int xc_fw_load_done:1;
460 struct mutex gpio_i2c_lock;
e0d3bafd
SD
461
462 /* video for linux */
84b5dbf3
MCC
463 int users; /* user count for exclusive use */
464 struct video_device *vdev; /* video for linux device struct */
465 v4l2_std_id norm; /* selected tv norm */
466 int ctl_freq; /* selected frequency */
467 unsigned int ctl_ainput; /* selected audio input */
e0d3bafd
SD
468 int mute;
469 int volume;
470
471 /* frame properties */
84b5dbf3
MCC
472 int width; /* current frame width */
473 int height; /* current frame height */
474 unsigned hscale; /* horizontal scale factor (see datasheet) */
475 unsigned vscale; /* vertical scale factor (see datasheet) */
476 int interlaced; /* 1=interlace fileds, 0=just top fileds */
e0d3bafd
SD
477
478 struct cx231xx_audio adev;
479
480 /* states */
481 enum cx231xx_dev_state state;
482
84b5dbf3 483 struct work_struct request_module_wk;
e0d3bafd
SD
484
485 /* locks */
486 struct mutex lock;
84b5dbf3 487 struct mutex ctrl_urb_lock; /* protects urb_buf */
e0d3bafd
SD
488 struct list_head inqueue, outqueue;
489 wait_queue_head_t open, wait_frame, wait_stream;
490 struct video_device *vbi_dev;
491 struct video_device *radio_dev;
492
493 unsigned char eedata[256];
494
84b5dbf3
MCC
495 struct cx231xx_video_mode video_mode;
496 struct cx231xx_video_mode vbi_mode;
497 struct cx231xx_video_mode sliced_cc_mode;
498 struct cx231xx_video_mode ts1_mode;
e0d3bafd 499
84b5dbf3
MCC
500 struct usb_device *udev; /* the usb device */
501 char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */
e0d3bafd
SD
502
503 /* helper funcs that call usb_control_msg */
cde4362f 504 int (*cx231xx_read_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg,
e0d3bafd 505 char *buf, int len);
cde4362f 506 int (*cx231xx_write_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg,
84b5dbf3 507 char *buf, int len);
cde4362f 508 int (*cx231xx_send_usb_command) (struct cx231xx_i2c *i2c_bus,
b9255176 509 struct cx231xx_i2c_xfer_data *req_data);
cde4362f
MCC
510 int (*cx231xx_gpio_i2c_read) (struct cx231xx *dev, u8 dev_addr,
511 u8 *buf, u8 len);
512 int (*cx231xx_gpio_i2c_write) (struct cx231xx *dev, u8 dev_addr,
513 u8 *buf, u8 len);
84b5dbf3 514
cde4362f
MCC
515 int (*cx231xx_set_analog_freq) (struct cx231xx *dev, u32 freq);
516 int (*cx231xx_reset_analog_tuner) (struct cx231xx *dev);
e0d3bafd
SD
517
518 enum cx231xx_mode mode;
519
520 struct cx231xx_dvb *dvb;
521
84b5dbf3
MCC
522 /* Cx231xx supported PCB config's */
523 struct pcb_config current_pcb_config;
524 u8 current_scenario_idx;
525 u8 interface_count;
526 u8 max_iad_interface_count;
e0d3bafd 527
84b5dbf3
MCC
528 /* GPIO related register direction and values */
529 u32 gpio_dir;
530 u32 gpio_val;
e0d3bafd 531
84b5dbf3
MCC
532 /* Power Modes */
533 int power_mode;
e0d3bafd 534
84b5dbf3
MCC
535 /* colibri parameters */
536 enum AFE_MODE colibri_mode;
537 u32 colibri_ref_count;
e0d3bafd 538
84b5dbf3
MCC
539 /* video related parameters */
540 u32 video_input;
541 u32 active_mode;
542 u8 vbi_or_sliced_cc_mode; /* 0 - vbi ; 1 - sliced cc mode */
543 enum cx231xx_std_mode std_mode; /* 0 - Air; 1 - cable */
e0d3bafd
SD
544
545};
546
547struct cx231xx_ops {
548 struct list_head next;
549 char *name;
550 int id;
84b5dbf3
MCC
551 int (*init) (struct cx231xx *);
552 int (*fini) (struct cx231xx *);
e0d3bafd
SD
553};
554
555/* call back functions in dvb module */
84b5dbf3
MCC
556int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq);
557int cx231xx_reset_analog_tuner(struct cx231xx *dev);
e0d3bafd
SD
558
559/* Provided by cx231xx-i2c.c */
84b5dbf3
MCC
560void cx231xx_i2c_call_clients(struct cx231xx_i2c *bus, unsigned int cmd,
561 void *arg);
e0d3bafd
SD
562void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c);
563int cx231xx_i2c_register(struct cx231xx_i2c *bus);
564int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
565
566/* Internal block control functions */
567int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr,
cde4362f 568 u16 saddr, u8 saddr_len, u32 *data, u8 data_len);
e0d3bafd 569int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr,
84b5dbf3
MCC
570 u16 saddr, u8 saddr_len, u32 data, u8 data_len);
571int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size,
572 u16 register_address, u8 bit_start, u8 bit_end,
573 u32 value);
e0d3bafd 574int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr,
84b5dbf3 575 u16 saddr, u32 mask, u32 value);
e0d3bafd
SD
576u32 cx231xx_set_field(u32 field_mask, u32 data);
577
578/* Colibri related functions */
579int cx231xx_colibri_init_super_block(struct cx231xx *dev, u32 ref_count);
580int cx231xx_colibri_init_channels(struct cx231xx *dev);
581int cx231xx_colibri_setup_AFE_for_baseband(struct cx231xx *dev);
582int cx231xx_colibri_set_input_mux(struct cx231xx *dev, u32 input_mux);
583int cx231xx_colibri_set_mode(struct cx231xx *dev, enum AFE_MODE mode);
584int cx231xx_colibri_update_power_control(struct cx231xx *dev, AV_MODE avmode);
585int cx231xx_colibri_adjust_ref_count(struct cx231xx *dev, u32 video_input);
586
587/* flatiron related functions */
588int cx231xx_flatiron_initialize(struct cx231xx *dev);
589int cx231xx_flatiron_update_power_control(struct cx231xx *dev, AV_MODE avmode);
590int cx231xx_flatiron_set_audio_input(struct cx231xx *dev, u8 audio_input);
591
592/* DIF related functions */
593int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode,
84b5dbf3 594 u32 function_mode, u32 standard);
e0d3bafd
SD
595int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard);
596int cx231xx_tuner_pre_channel_change(struct cx231xx *dev);
597int cx231xx_tuner_post_channel_change(struct cx231xx *dev);
598
599/* video parser functions */
cde4362f
MCC
600u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size,
601 u32 *p_bytes_used);
602u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf,
603 u32 *p_bytes_used);
e0d3bafd 604int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
cde4362f 605 u8 *p_buffer, u32 bytes_to_copy);
84b5dbf3
MCC
606void cx231xx_reset_video_buffer(struct cx231xx *dev,
607 struct cx231xx_dmaqueue *dma_q);
608u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q);
609u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
cde4362f 610 u8 *p_line, u32 length, int field_number);
84b5dbf3 611u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q,
cde4362f
MCC
612 u8 sav_eav, u8 *p_buffer, u32 buffer_size);
613void cx231xx_swab(u16 *from, u16 *to, u16 len);
e0d3bafd
SD
614
615/* Provided by cx231xx-core.c */
616
617u32 cx231xx_request_buffers(struct cx231xx *dev, u32 count);
618void cx231xx_queue_unusedframes(struct cx231xx *dev);
619void cx231xx_release_buffers(struct cx231xx *dev);
620
621/* read from control pipe */
622int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
84b5dbf3 623 char *buf, int len);
e0d3bafd
SD
624
625/* write to control pipe */
626int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg,
84b5dbf3 627 char *buf, int len);
e0d3bafd
SD
628int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode);
629
b9255176
SD
630int cx231xx_send_vendor_cmd(struct cx231xx *dev,
631 struct VENDOR_REQUEST_IN *ven_req);
e0d3bafd 632int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus,
b9255176 633 struct cx231xx_i2c_xfer_data *req_data);
e0d3bafd
SD
634
635/* Gpio related functions */
cde4362f 636int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val,
84b5dbf3 637 u8 len, u8 request, u8 direction);
cde4362f
MCC
638int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val);
639int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val);
e0d3bafd 640int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value);
84b5dbf3
MCC
641int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number,
642 int pin_value);
e0d3bafd
SD
643
644int cx231xx_gpio_i2c_start(struct cx231xx *dev);
645int cx231xx_gpio_i2c_end(struct cx231xx *dev);
646int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data);
cde4362f 647int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf);
e0d3bafd
SD
648int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev);
649int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev);
650int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev);
651
cde4362f
MCC
652int 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);
e0d3bafd
SD
654
655/* audio related functions */
84b5dbf3
MCC
656int cx231xx_set_audio_decoder_input(struct cx231xx *dev,
657 enum AUDIO_INPUT audio_input);
e0d3bafd
SD
658
659int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type);
660int cx231xx_resolution_set(struct cx231xx *dev);
661int cx231xx_set_video_alternate(struct cx231xx *dev);
662int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt);
663int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
84b5dbf3 664 int num_bufs, int max_pkt_size,
cde4362f
MCC
665 int (*isoc_copy) (struct cx231xx *dev,
666 struct urb *urb));
e0d3bafd
SD
667void cx231xx_uninit_isoc(struct cx231xx *dev);
668int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode);
669int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio);
670
671/* Device list functions */
672void cx231xx_release_resources(struct cx231xx *dev);
673void cx231xx_release_analog_resources(struct cx231xx *dev);
674int cx231xx_register_analog_devices(struct cx231xx *dev);
675void cx231xx_remove_from_devlist(struct cx231xx *dev);
676void cx231xx_add_into_devlist(struct cx231xx *dev);
677struct cx231xx *cx231xx_get_device(int minor,
84b5dbf3 678 enum v4l2_buf_type *fh_type, int *has_radio);
e0d3bafd
SD
679void cx231xx_init_extension(struct cx231xx *dev);
680void cx231xx_close_extension(struct cx231xx *dev);
681
682/* hardware init functions */
683int cx231xx_dev_init(struct cx231xx *dev);
684void cx231xx_dev_uninit(struct cx231xx *dev);
685void cx231xx_config_i2c(struct cx231xx *dev);
686int cx231xx_config(struct cx231xx *dev);
687
688/* Stream control functions */
689int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask);
690int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask);
691
692int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type);
693
694/* Power control functions */
695int cx231xx_set_power_mode(struct cx231xx *dev, AV_MODE mode);
696int cx231xx_power_suspend(struct cx231xx *dev);
697
698/* chip specific control functions */
699int cx231xx_init_ctrl_pin_status(struct cx231xx *dev);
84b5dbf3
MCC
700int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev,
701 u8 analog_or_digital);
e0d3bafd
SD
702int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex);
703
704/* video audio decoder related functions */
705void video_mux(struct cx231xx *dev, int index);
706int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input);
707int cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input);
708int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev);
709int cx231xx_set_audio_input(struct cx231xx *dev, u8 input);
710void get_scale(struct cx231xx *dev,
84b5dbf3
MCC
711 unsigned int width, unsigned int height,
712 unsigned int *hscale, unsigned int *vscale);
e0d3bafd
SD
713
714/* Provided by cx231xx-video.c */
715int cx231xx_register_extension(struct cx231xx_ops *dev);
716void cx231xx_unregister_extension(struct cx231xx_ops *dev);
717void cx231xx_init_extension(struct cx231xx *dev);
718void cx231xx_close_extension(struct cx231xx *dev);
719
720/* Provided by cx231xx-cards.c */
721extern void cx231xx_pre_card_setup(struct cx231xx *dev);
722extern void cx231xx_card_setup(struct cx231xx *dev);
723extern struct cx231xx_board cx231xx_boards[];
724extern struct usb_device_id cx231xx_id_table[];
725extern const unsigned int cx231xx_bcount;
726void cx231xx_set_ir(struct cx231xx *dev, struct IR_i2c *ir);
727int cx231xx_tuner_callback(void *ptr, int component, int command, int arg);
728
729/* Provided by cx231xx-input.c */
730int cx231xx_ir_init(struct cx231xx *dev);
731int cx231xx_ir_fini(struct cx231xx *dev);
732
733/* printk macros */
734
735#define cx231xx_err(fmt, arg...) do {\
736 printk(KERN_ERR fmt , ##arg); } while (0)
737
738#define cx231xx_errdev(fmt, arg...) do {\
739 printk(KERN_ERR "%s: "fmt,\
740 dev->name , ##arg); } while (0)
741
742#define cx231xx_info(fmt, arg...) do {\
743 printk(KERN_INFO "%s: "fmt,\
744 dev->name , ##arg); } while (0)
745#define cx231xx_warn(fmt, arg...) do {\
746 printk(KERN_WARNING "%s: "fmt,\
747 dev->name , ##arg); } while (0)
748
e0d3bafd
SD
749static inline unsigned int norm_maxw(struct cx231xx *dev)
750{
751 if (dev->board.max_range_640_480)
752 return 640;
753 else
754 return 720;
755}
756
757static inline unsigned int norm_maxh(struct cx231xx *dev)
758{
759 if (dev->board.max_range_640_480)
760 return 480;
761 else
762 return (dev->norm & V4L2_STD_625_50) ? 576 : 480;
763}
764#endif