]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - drivers/media/i2c/msp3400-driver.h
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[mirror_ubuntu-kernels.git] / drivers / media / i2c / msp3400-driver.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
56fc08ca 2/*
56fc08ca
MCC
3 */
4
49965a80
HV
5#ifndef MSP3400_DRIVER_H
6#define MSP3400_DRIVER_H
1da177e4 7
d647f0b7 8#include <media/drv-intf/msp3400.h>
76efd62f 9#include <media/v4l2-device.h>
ebc3bba5 10#include <media/v4l2-ctrls.h>
fb493282 11#include <media/v4l2-mc.h>
2474ed44 12
1da177e4
LT
13/* ---------------------------------------------------------------------- */
14
53b0a1c6
HV
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)))
18
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
28
42772574
HV
29#define SCART_IN1 0
30#define SCART_IN2 1
31#define SCART_IN3 2
32#define SCART_IN4 3
33#define SCART_IN1_DA 4
34#define SCART_IN2_DA 5
35#define SCART_MONO 6
36#define SCART_MUTE 7
1da177e4
LT
37
38#define SCART_DSP_IN 0
39#define SCART1_OUT 1
40#define SCART2_OUT 2
41
53b0a1c6
HV
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) */
46
47/* module parameters */
f167cb4e 48extern int msp_debug;
90ab5ee9
RR
49extern bool msp_once;
50extern bool msp_amsound;
f167cb4e 51extern int msp_standard;
90ab5ee9 52extern bool msp_dolby;
f167cb4e 53extern int msp_stereo_thresh;
53b0a1c6
HV
54
55struct msp_state {
76efd62f 56 struct v4l2_subdev sd;
ebc3bba5 57 struct v4l2_ctrl_handler hdl;
53b0a1c6 58 int rev1, rev2;
74cab31c 59 int ident;
5af0c8f6
HV
60 u8 has_nicam;
61 u8 has_radio;
62 u8 has_headphones;
63 u8 has_ntsc_jp_d_k3;
0020d3ef
HV
64 u8 has_scart2;
65 u8 has_scart3;
5af0c8f6 66 u8 has_scart4;
0020d3ef 67 u8 has_scart2_out;
5af0c8f6
HV
68 u8 has_scart2_out_volume;
69 u8 has_i2s_conf;
70 u8 has_subwoofer;
71 u8 has_sound_processing;
72 u8 has_virtual_dolby_surround;
73 u8 has_dolby_pro_logic;
de98cdaf 74 u8 force_btsc;
7560d7a4
HV
75
76 int radio;
53b0a1c6 77 int opmode;
5af0c8f6 78 int std;
53b0a1c6 79 int mode;
5d1ed986 80 v4l2_std_id v4l2_std, detected_std;
53b0a1c6
HV
81 int nicam_on;
82 int acb;
83 int in_scart;
84 int i2s_mode;
85 int main, second; /* sound carrier */
86 int input;
5325b427
HV
87 u32 route_in;
88 u32 route_out;
53b0a1c6
HV
89
90 /* v4l2 */
91 int audmode;
92 int rxsubchans;
93
ebc3bba5
HV
94 struct {
95 /* volume cluster */
96 struct v4l2_ctrl *volume;
97 struct v4l2_ctrl *muted;
98 };
99
3bbe5a83 100 int scan_in_progress;
53b0a1c6
HV
101
102 /* thread */
103 struct task_struct *kthread;
104 wait_queue_head_t wq;
0a115373
RD
105 unsigned int restart:1;
106 unsigned int watch_stereo:1;
fb493282 107
24095e76 108#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
fb493282
MCC
109 struct media_pad pads[IF_AUD_DEC_PAD_NUM_PADS];
110#endif
53b0a1c6
HV
111};
112
76efd62f
HV
113static inline struct msp_state *to_state(struct v4l2_subdev *sd)
114{
115 return container_of(sd, struct msp_state, sd);
116}
117
ebc3bba5
HV
118static inline struct msp_state *ctrl_to_state(struct v4l2_ctrl *ctrl)
119{
120 return container_of(ctrl->handler, struct msp_state, hdl);
121}
122
53b0a1c6
HV
123/* msp3400-driver.c */
124int msp_write_dem(struct i2c_client *client, int addr, int val);
125int msp_write_dsp(struct i2c_client *client, int addr, int val);
126int msp_read_dem(struct i2c_client *client, int addr);
127int msp_read_dsp(struct i2c_client *client, int addr);
128int msp_reset(struct i2c_client *client);
129void msp_set_scart(struct i2c_client *client, int in, int out);
ebc3bba5 130void msp_update_volume(struct msp_state *state);
53b0a1c6
HV
131int msp_sleep(struct msp_state *state, int timeout);
132
133/* msp3400-kthreads.c */
5af0c8f6 134const char *msp_standard_std_name(int std);
8a4b275f 135void msp_set_audmode(struct i2c_client *client);
de533ccf 136int msp_detect_stereo(struct i2c_client *client);
53b0a1c6
HV
137int msp3400c_thread(void *data);
138int msp3410d_thread(void *data);
139int msp34xxg_thread(void *data);
8a4b275f
HV
140void msp3400c_set_mode(struct i2c_client *client, int mode);
141void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
53b0a1c6 142
49965a80 143#endif /* MSP3400_DRIVER_H */