blob: 33d64ac75d372ba79adfbab9dc7897c49b59356d [file] [log] [blame]
Mauro Carvalho Chehab56fc08c2005-06-23 22:05:07 -07001/*
Mauro Carvalho Chehab56fc08c2005-06-23 22:05:07 -07002 */
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#ifndef MSP3400_H
5#define MSP3400_H
6
7/* ---------------------------------------------------------------------- */
8
Hans Verkuil53b0a1c2006-01-09 15:32:39 -02009#define msp_err(fmt, arg...) \
10 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
11 i2c_adapter_id(client->adapter), client->addr , ## arg)
12#define msp_warn(fmt, arg...) \
13 printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \
14 i2c_adapter_id(client->adapter), client->addr , ## arg)
15#define msp_info(fmt, arg...) \
16 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
17 i2c_adapter_id(client->adapter), client->addr , ## arg)
18
19/* level 1 debug. */
20#define msp_dbg1(fmt, arg...) \
21 do { \
22 if (debug) \
23 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->driver.name, \
24 i2c_adapter_id(client->adapter), client->addr , ## arg); \
25 } while (0)
26
27/* level 2 debug. */
28#define msp_dbg2(fmt, arg...) \
29 do { \
30 if (debug >= 2) \
31 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
32 i2c_adapter_id(client->adapter), client->addr , ## arg); \
33 } while (0)
34
35/* level 3 debug. Use with care. */
36#define msp_dbg3(fmt, arg...) \
37 do { \
38 if (debug >= 16) \
39 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
40 i2c_adapter_id(client->adapter), client->addr , ## arg); \
41 } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43struct msp_matrix {
44 int input;
45 int output;
46};
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048/* ioctl for MSP_SET_MATRIX will have to be registered */
49#define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix)
50
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020051/* This macro is allowed for *constants* only, gcc must calculate it
52 at compile time. Remember -- no floats in kernel mode */
53#define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24)))
54
55#define MSP_MODE_AM_DETECT 0
56#define MSP_MODE_FM_RADIO 2
57#define MSP_MODE_FM_TERRA 3
58#define MSP_MODE_FM_SAT 4
59#define MSP_MODE_FM_NICAM1 5
60#define MSP_MODE_FM_NICAM2 6
61#define MSP_MODE_AM_NICAM 7
62#define MSP_MODE_BTSC 8
63#define MSP_MODE_EXTERN 9
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#define SCART_MASK 0
66#define SCART_IN1 1
67#define SCART_IN2 2
68#define SCART_IN1_DA 3
69#define SCART_IN2_DA 4
70#define SCART_IN3 5
71#define SCART_IN4 6
72#define SCART_MONO 7
73#define SCART_MUTE 8
74
75#define SCART_DSP_IN 0
76#define SCART1_OUT 1
77#define SCART2_OUT 2
78
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020079#define OPMODE_AUTO -1
80#define OPMODE_MANUAL 0
81#define OPMODE_AUTODETECT 1 /* use autodetect (>= msp3410 only) */
82#define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */
83
84/* module parameters */
85extern int debug;
86extern int once;
87extern int amsound;
88extern int standard;
89extern int dolby;
90extern int stereo_threshold;
91
92struct msp_state {
93 int rev1, rev2;
94
95 int opmode;
96 int mode;
97 int norm;
98 int stereo;
99 int nicam_on;
100 int acb;
101 int in_scart;
102 int i2s_mode;
103 int main, second; /* sound carrier */
104 int input;
105 int source; /* see msp34xxg_set_source */
106
107 /* v4l2 */
108 int audmode;
109 int rxsubchans;
110
111 int muted;
112 int volume, balance;
113 int bass, treble;
114
115 /* thread */
116 struct task_struct *kthread;
117 wait_queue_head_t wq;
118 int restart:1;
119 int watch_stereo:1;
120};
121
122#define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */
123
124#define HAVE_NICAM(state) (((state->rev2 >> 8) & 0xff) != 0)
125#define HAVE_RADIO(state) ((state->rev1 & 0x0f) >= 'G'-'@')
126
127/* msp3400-driver.c */
128int msp_write_dem(struct i2c_client *client, int addr, int val);
129int msp_write_dsp(struct i2c_client *client, int addr, int val);
130int msp_read_dem(struct i2c_client *client, int addr);
131int msp_read_dsp(struct i2c_client *client, int addr);
132int msp_reset(struct i2c_client *client);
133void msp_set_scart(struct i2c_client *client, int in, int out);
134void msp_set_mute(struct i2c_client *client);
135void msp_set_audio(struct i2c_client *client);
136int msp_modus(struct i2c_client *client, int norm);
137int msp_standard(int norm);
138int msp_sleep(struct msp_state *state, int timeout);
139
140/* msp3400-kthreads.c */
141const char *msp_standard_mode_name(int mode);
142void msp3400c_setcarrier(struct i2c_client *client, int cdo1, int cdo2);
143void msp3400c_setmode(struct i2c_client *client, int type);
144void msp3400c_setstereo(struct i2c_client *client, int mode);
145int autodetect_stereo(struct i2c_client *client);
146int msp3400c_thread(void *data);
147int msp3410d_thread(void *data);
148int msp34xxg_thread(void *data);
149void msp34xxg_detect_stereo(struct i2c_client *client);
150void msp34xxg_set_audmode(struct i2c_client *client, int audmode);
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152#endif /* MSP3400_H */