1 /* SPDX-License-Identifier: GPL-2.0 */
5 #ifndef MSP3400_DRIVER_H
6 #define MSP3400_DRIVER_H
8 #include <media/drv-intf/msp3400.h>
9 #include <media/v4l2-device.h>
10 #include <media/v4l2-ctrls.h>
11 #include <media/v4l2-mc.h>
13 /* ---------------------------------------------------------------------- */
15 /* This macro is allowed for *constants* only, gcc must calculate it
16 at compile time. Remember -- no floats in kernel mode */
17 #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24)))
19 #define MSP_MODE_AM_DETECT 0
20 #define MSP_MODE_FM_RADIO 2
21 #define MSP_MODE_FM_TERRA 3
22 #define MSP_MODE_FM_SAT 4
23 #define MSP_MODE_FM_NICAM1 5
24 #define MSP_MODE_FM_NICAM2 6
25 #define MSP_MODE_AM_NICAM 7
26 #define MSP_MODE_BTSC 8
27 #define MSP_MODE_EXTERN 9
33 #define SCART_IN1_DA 4
34 #define SCART_IN2_DA 5
38 #define SCART_DSP_IN 0
42 #define OPMODE_AUTO -1
43 #define OPMODE_MANUAL 0
44 #define OPMODE_AUTODETECT 1 /* use autodetect (>= msp3410 only) */
45 #define OPMODE_AUTOSELECT 2 /* use autodetect & autoselect (>= msp34xxG) */
47 /* module parameters */
50 extern bool msp_amsound
;
51 extern int msp_standard
;
52 extern bool msp_dolby
;
53 extern int msp_stereo_thresh
;
62 struct v4l2_subdev sd
;
63 struct v4l2_ctrl_handler hdl
;
74 u8 has_scart2_out_volume
;
77 u8 has_sound_processing
;
78 u8 has_virtual_dolby_surround
;
79 u8 has_dolby_pro_logic
;
86 v4l2_std_id v4l2_std
, detected_std
;
91 int main
, second
; /* sound carrier */
102 struct v4l2_ctrl
*volume
;
103 struct v4l2_ctrl
*muted
;
106 int scan_in_progress
;
109 struct task_struct
*kthread
;
110 wait_queue_head_t wq
;
111 unsigned int restart
:1;
112 unsigned int watch_stereo
:1;
114 #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
115 struct media_pad pads
[MSP3400_NUM_PADS
];
119 static inline struct msp_state
*to_state(struct v4l2_subdev
*sd
)
121 return container_of(sd
, struct msp_state
, sd
);
124 static inline struct msp_state
*ctrl_to_state(struct v4l2_ctrl
*ctrl
)
126 return container_of(ctrl
->handler
, struct msp_state
, hdl
);
129 /* msp3400-driver.c */
130 int msp_write_dem(struct i2c_client
*client
, int addr
, int val
);
131 int msp_write_dsp(struct i2c_client
*client
, int addr
, int val
);
132 int msp_read_dem(struct i2c_client
*client
, int addr
);
133 int msp_read_dsp(struct i2c_client
*client
, int addr
);
134 int msp_reset(struct i2c_client
*client
);
135 void msp_set_scart(struct i2c_client
*client
, int in
, int out
);
136 void msp_update_volume(struct msp_state
*state
);
137 int msp_sleep(struct msp_state
*state
, int timeout
);
139 /* msp3400-kthreads.c */
140 const char *msp_standard_std_name(int std
);
141 void msp_set_audmode(struct i2c_client
*client
);
142 int msp_detect_stereo(struct i2c_client
*client
);
143 int msp3400c_thread(void *data
);
144 int msp3410d_thread(void *data
);
145 int msp34xxg_thread(void *data
);
146 void msp3400c_set_mode(struct i2c_client
*client
, int mode
);
147 void msp3400c_set_carrier(struct i2c_client
*client
, int cdo1
, int cdo2
);
149 #endif /* MSP3400_DRIVER_H */