dc58d4292a34c4713bad772fc238b2104bfdb90b
[pandora-kernel.git] / drivers / media / video / cx25840 / cx25840.h
1 /* cx25840 API header
2  *
3  * Copyright (C) 2003-2004 Chris Kennedy
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef _CX25840_H_
21 #define _CX25840_H_
22
23
24 #include <linux/videodev2.h>
25 #include <linux/i2c.h>
26
27 extern int cx25840_debug;
28
29 #define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \
30         printk(KERN_INFO "%s debug %d-%04x: " fmt, \
31                client->driver->driver.name, \
32                i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
33
34 #define cx25840_err(fmt, arg...) do { \
35         printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
36                i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
37
38 #define cx25840_info(fmt, arg...) do { \
39         printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
40                i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
41
42 /* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is
43    present in Hauppauge PVR-150 (and possibly PVR-500) cards that have
44    certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The
45    audio autodetect fails on some channels for these models and the workaround
46    is to select the audio standard explicitly. Many thanks to Hauppauge for
47    providing this information. */
48 #define CX25840_CID_ENABLE_PVR150_WORKAROUND (V4L2_CID_PRIVATE_BASE+0)
49
50 enum cx25840_video_input {
51         /* Composite video inputs In1-In8 */
52         CX25840_COMPOSITE1 = 1,
53         CX25840_COMPOSITE2,
54         CX25840_COMPOSITE3,
55         CX25840_COMPOSITE4,
56         CX25840_COMPOSITE5,
57         CX25840_COMPOSITE6,
58         CX25840_COMPOSITE7,
59         CX25840_COMPOSITE8,
60
61         /* S-Video inputs consist of one luma input (In1-In4) ORed with one
62            chroma input (In5-In8) */
63         CX25840_SVIDEO_LUMA1 = 0x10,
64         CX25840_SVIDEO_LUMA2 = 0x20,
65         CX25840_SVIDEO_LUMA3 = 0x30,
66         CX25840_SVIDEO_LUMA4 = 0x40,
67         CX25840_SVIDEO_CHROMA4 = 0x400,
68         CX25840_SVIDEO_CHROMA5 = 0x500,
69         CX25840_SVIDEO_CHROMA6 = 0x600,
70         CX25840_SVIDEO_CHROMA7 = 0x700,
71         CX25840_SVIDEO_CHROMA8 = 0x800,
72
73         /* S-Video aliases for common luma/chroma combinations */
74         CX25840_SVIDEO1 = 0x510,
75         CX25840_SVIDEO2 = 0x620,
76         CX25840_SVIDEO3 = 0x730,
77         CX25840_SVIDEO4 = 0x840,
78 };
79
80 enum cx25840_audio_input {
81         /* Audio inputs: serial or In4-In8 */
82         CX25840_AUDIO_SERIAL,
83         CX25840_AUDIO4 = 4,
84         CX25840_AUDIO5,
85         CX25840_AUDIO6,
86         CX25840_AUDIO7,
87         CX25840_AUDIO8,
88 };
89
90 struct cx25840_state {
91         int pvr150_workaround;
92         int radio;
93         enum cx25840_video_input vid_input;
94         enum cx25840_audio_input aud_input;
95         u32 audclk_freq;
96 };
97
98 /* ----------------------------------------------------------------------- */
99 /* cx25850-core.c                                                          */
100 int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
101 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value);
102 u8 cx25840_read(struct i2c_client *client, u16 addr);
103 u32 cx25840_read4(struct i2c_client *client, u16 addr);
104 int cx25840_and_or(struct i2c_client *client, u16 addr, u8 mask, u8 value);
105 v4l2_std_id cx25840_get_v4lstd(struct i2c_client *client);
106
107 /* ----------------------------------------------------------------------- */
108 /* cx25850-firmware.c                                                      */
109 int cx25840_loadfw(struct i2c_client *client);
110
111 /* ----------------------------------------------------------------------- */
112 /* cx25850-audio.c                                                         */
113 int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg);
114 void cx25840_audio_set_path(struct i2c_client *client);
115
116 /* ----------------------------------------------------------------------- */
117 /* cx25850-vbi.c                                                           */
118 void cx25840_vbi_setup(struct i2c_client *client);
119 int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg);
120
121 #endif