blob: 831e8db4368c06e23915518b82abb56dde84fcd1 [file] [log] [blame]
Mauro Carvalho Chehab56fc08c2005-06-23 22:05:07 -07001/*
Mauro Carvalho Chehab56fc08c2005-06-23 22:05:07 -07002 */
3
Hans Verkuil49965a82006-03-19 08:45:38 -03004#ifndef MSP3400_DRIVER_H
5#define MSP3400_DRIVER_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Hans Verkuil2474ed42006-03-19 12:35:57 -03007#include <media/msp3400.h>
Hans Verkuil76efd622008-11-24 18:16:46 -03008#include <media/v4l2-device.h>
Hans Verkuilebc3bba2010-05-24 10:01:58 -03009#include <media/v4l2-ctrls.h>
Hans Verkuil2474ed42006-03-19 12:35:57 -030010
Linus Torvalds1da177e2005-04-16 15:20:36 -070011/* ---------------------------------------------------------------------- */
12
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020013/* This macro is allowed for *constants* only, gcc must calculate it
14 at compile time. Remember -- no floats in kernel mode */
15#define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24)))
16
17#define MSP_MODE_AM_DETECT 0
18#define MSP_MODE_FM_RADIO 2
19#define MSP_MODE_FM_TERRA 3
20#define MSP_MODE_FM_SAT 4
21#define MSP_MODE_FM_NICAM1 5
22#define MSP_MODE_FM_NICAM2 6
23#define MSP_MODE_AM_NICAM 7
24#define MSP_MODE_BTSC 8
25#define MSP_MODE_EXTERN 9
26
Hans Verkuil42772572006-03-19 06:48:51 -030027#define SCART_IN1 0
28#define SCART_IN2 1
29#define SCART_IN3 2
30#define SCART_IN4 3
31#define SCART_IN1_DA 4
32#define SCART_IN2_DA 5
33#define SCART_MONO 6
34#define SCART_MUTE 7
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36#define SCART_DSP_IN 0
37#define SCART1_OUT 1
38#define SCART2_OUT 2
39
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020040#define OPMODE_AUTO -1
41#define OPMODE_MANUAL 0
42#define OPMODE_AUTODETECT 1 /* use autodetect (>= msp3410 only) */
43#define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */
44
45/* module parameters */
Mauro Carvalho Chehabf167cb4e2006-01-11 19:41:49 -020046extern int msp_debug;
47extern int msp_once;
48extern int msp_amsound;
49extern int msp_standard;
50extern int msp_dolby;
51extern int msp_stereo_thresh;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020052
53struct msp_state {
Hans Verkuil76efd622008-11-24 18:16:46 -030054 struct v4l2_subdev sd;
Hans Verkuilebc3bba2010-05-24 10:01:58 -030055 struct v4l2_ctrl_handler hdl;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020056 int rev1, rev2;
Hans Verkuil74cab312007-04-27 12:31:26 -030057 int ident;
Hans Verkuil5af0c8f2006-01-09 18:21:37 -020058 u8 has_nicam;
59 u8 has_radio;
60 u8 has_headphones;
61 u8 has_ntsc_jp_d_k3;
Hans Verkuil0020d3e2006-03-30 19:50:34 -030062 u8 has_scart2;
63 u8 has_scart3;
Hans Verkuil5af0c8f2006-01-09 18:21:37 -020064 u8 has_scart4;
Hans Verkuil0020d3e2006-03-30 19:50:34 -030065 u8 has_scart2_out;
Hans Verkuil5af0c8f2006-01-09 18:21:37 -020066 u8 has_scart2_out_volume;
67 u8 has_i2s_conf;
68 u8 has_subwoofer;
69 u8 has_sound_processing;
70 u8 has_virtual_dolby_surround;
71 u8 has_dolby_pro_logic;
Hans Verkuilde98cda2006-10-01 17:56:32 -030072 u8 force_btsc;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020073
Hans Verkuil7560d7a2006-01-09 18:21:32 -020074 int radio;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020075 int opmode;
Hans Verkuil5af0c8f2006-01-09 18:21:37 -020076 int std;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020077 int mode;
Mauro Carvalho Chehab5d1ed982011-10-04 09:44:02 -030078 v4l2_std_id v4l2_std, detected_std;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020079 int nicam_on;
80 int acb;
81 int in_scart;
82 int i2s_mode;
83 int main, second; /* sound carrier */
84 int input;
Hans Verkuil5325b422009-04-02 11:26:22 -030085 u32 route_in;
86 u32 route_out;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020087
88 /* v4l2 */
89 int audmode;
90 int rxsubchans;
91
Hans Verkuilebc3bba2010-05-24 10:01:58 -030092 struct {
93 /* volume cluster */
94 struct v4l2_ctrl *volume;
95 struct v4l2_ctrl *muted;
96 };
97
Hans Verkuil3bbe5a82006-04-01 15:27:52 -030098 int scan_in_progress;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -020099
100 /* thread */
101 struct task_struct *kthread;
102 wait_queue_head_t wq;
Randy Dunlap0a115372006-06-28 15:05:11 -0300103 unsigned int restart:1;
104 unsigned int watch_stereo:1;
Hans Verkuil53b0a1c2006-01-09 15:32:39 -0200105};
106
Hans Verkuil76efd622008-11-24 18:16:46 -0300107static inline struct msp_state *to_state(struct v4l2_subdev *sd)
108{
109 return container_of(sd, struct msp_state, sd);
110}
111
Hans Verkuilebc3bba2010-05-24 10:01:58 -0300112static inline struct msp_state *ctrl_to_state(struct v4l2_ctrl *ctrl)
113{
114 return container_of(ctrl->handler, struct msp_state, hdl);
115}
116
Hans Verkuil53b0a1c2006-01-09 15:32:39 -0200117/* msp3400-driver.c */
118int msp_write_dem(struct i2c_client *client, int addr, int val);
119int msp_write_dsp(struct i2c_client *client, int addr, int val);
120int msp_read_dem(struct i2c_client *client, int addr);
121int msp_read_dsp(struct i2c_client *client, int addr);
122int msp_reset(struct i2c_client *client);
123void msp_set_scart(struct i2c_client *client, int in, int out);
Hans Verkuilebc3bba2010-05-24 10:01:58 -0300124void msp_update_volume(struct msp_state *state);
Hans Verkuil53b0a1c2006-01-09 15:32:39 -0200125int msp_sleep(struct msp_state *state, int timeout);
126
127/* msp3400-kthreads.c */
Hans Verkuil5af0c8f2006-01-09 18:21:37 -0200128const char *msp_standard_std_name(int std);
Hans Verkuil8a4b2752006-01-23 17:11:09 -0200129void msp_set_audmode(struct i2c_client *client);
Hans Verkuilde533cc2006-03-19 08:21:56 -0300130int msp_detect_stereo(struct i2c_client *client);
Hans Verkuil53b0a1c2006-01-09 15:32:39 -0200131int msp3400c_thread(void *data);
132int msp3410d_thread(void *data);
133int msp34xxg_thread(void *data);
Hans Verkuil8a4b2752006-01-23 17:11:09 -0200134void msp3400c_set_mode(struct i2c_client *client, int mode);
135void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
Hans Verkuil53b0a1c2006-01-09 15:32:39 -0200136
Hans Verkuil49965a82006-03-19 08:45:38 -0300137#endif /* MSP3400_DRIVER_H */