0001
0002
0003
0004
0005 #ifndef MSP3400_DRIVER_H
0006 #define MSP3400_DRIVER_H
0007
0008 #include <media/drv-intf/msp3400.h>
0009 #include <media/v4l2-device.h>
0010 #include <media/v4l2-ctrls.h>
0011 #include <media/v4l2-mc.h>
0012
0013
0014
0015
0016
0017 #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24)))
0018
0019 #define MSP_MODE_AM_DETECT 0
0020 #define MSP_MODE_FM_RADIO 2
0021 #define MSP_MODE_FM_TERRA 3
0022 #define MSP_MODE_FM_SAT 4
0023 #define MSP_MODE_FM_NICAM1 5
0024 #define MSP_MODE_FM_NICAM2 6
0025 #define MSP_MODE_AM_NICAM 7
0026 #define MSP_MODE_BTSC 8
0027 #define MSP_MODE_EXTERN 9
0028
0029 #define SCART_IN1 0
0030 #define SCART_IN2 1
0031 #define SCART_IN3 2
0032 #define SCART_IN4 3
0033 #define SCART_IN1_DA 4
0034 #define SCART_IN2_DA 5
0035 #define SCART_MONO 6
0036 #define SCART_MUTE 7
0037
0038 #define SCART_DSP_IN 0
0039 #define SCART1_OUT 1
0040 #define SCART2_OUT 2
0041
0042 #define OPMODE_AUTO -1
0043 #define OPMODE_MANUAL 0
0044 #define OPMODE_AUTODETECT 1
0045 #define OPMODE_AUTOSELECT 2
0046
0047
0048 extern int msp_debug;
0049 extern bool msp_once;
0050 extern bool msp_amsound;
0051 extern int msp_standard;
0052 extern bool msp_dolby;
0053 extern int msp_stereo_thresh;
0054
0055 enum msp3400_pads {
0056 MSP3400_PAD_IF_INPUT,
0057 MSP3400_PAD_OUT,
0058 MSP3400_NUM_PADS
0059 };
0060
0061 struct msp_state {
0062 struct v4l2_subdev sd;
0063 struct v4l2_ctrl_handler hdl;
0064 int rev1, rev2;
0065 int ident;
0066 u8 has_nicam;
0067 u8 has_radio;
0068 u8 has_headphones;
0069 u8 has_ntsc_jp_d_k3;
0070 u8 has_scart2;
0071 u8 has_scart3;
0072 u8 has_scart4;
0073 u8 has_scart2_out;
0074 u8 has_scart2_out_volume;
0075 u8 has_i2s_conf;
0076 u8 has_subwoofer;
0077 u8 has_sound_processing;
0078 u8 has_virtual_dolby_surround;
0079 u8 has_dolby_pro_logic;
0080 u8 force_btsc;
0081
0082 int radio;
0083 int opmode;
0084 int std;
0085 int mode;
0086 v4l2_std_id v4l2_std, detected_std;
0087 int nicam_on;
0088 int acb;
0089 int in_scart;
0090 int i2s_mode;
0091 int main, second;
0092 int input;
0093 u32 route_in;
0094 u32 route_out;
0095
0096
0097 int audmode;
0098 int rxsubchans;
0099
0100 struct {
0101
0102 struct v4l2_ctrl *volume;
0103 struct v4l2_ctrl *muted;
0104 };
0105
0106 int scan_in_progress;
0107
0108
0109 struct task_struct *kthread;
0110 wait_queue_head_t wq;
0111 unsigned int restart:1;
0112 unsigned int watch_stereo:1;
0113
0114 #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
0115 struct media_pad pads[MSP3400_NUM_PADS];
0116 #endif
0117 };
0118
0119 static inline struct msp_state *to_state(struct v4l2_subdev *sd)
0120 {
0121 return container_of(sd, struct msp_state, sd);
0122 }
0123
0124 static inline struct msp_state *ctrl_to_state(struct v4l2_ctrl *ctrl)
0125 {
0126 return container_of(ctrl->handler, struct msp_state, hdl);
0127 }
0128
0129
0130 int msp_write_dem(struct i2c_client *client, int addr, int val);
0131 int msp_write_dsp(struct i2c_client *client, int addr, int val);
0132 int msp_read_dem(struct i2c_client *client, int addr);
0133 int msp_read_dsp(struct i2c_client *client, int addr);
0134 int msp_reset(struct i2c_client *client);
0135 void msp_set_scart(struct i2c_client *client, int in, int out);
0136 void msp_update_volume(struct msp_state *state);
0137 int msp_sleep(struct msp_state *state, int timeout);
0138
0139
0140 const char *msp_standard_std_name(int std);
0141 void msp_set_audmode(struct i2c_client *client);
0142 int msp_detect_stereo(struct i2c_client *client);
0143 int msp3400c_thread(void *data);
0144 int msp3410d_thread(void *data);
0145 int msp34xxg_thread(void *data);
0146 void msp3400c_set_mode(struct i2c_client *client, int mode);
0147 void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
0148
0149 #endif