Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifndef MSP3400_DRIVER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #define MSP3400_DRIVER_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <media/drv-intf/msp3400.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <media/v4l2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <media/v4l2-mc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /* ---------------------------------------------------------------------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* This macro is allowed for *constants* only, gcc must calculate it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)    at compile time.  Remember -- no floats in kernel mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define MSP_MODE_AM_DETECT   0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define MSP_MODE_FM_RADIO    2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define MSP_MODE_FM_TERRA    3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define MSP_MODE_FM_SAT      4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define MSP_MODE_FM_NICAM1   5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define MSP_MODE_FM_NICAM2   6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define MSP_MODE_AM_NICAM    7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define MSP_MODE_BTSC        8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define MSP_MODE_EXTERN      9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define SCART_IN1     0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define SCART_IN2     1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define SCART_IN3     2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define SCART_IN4     3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define SCART_IN1_DA  4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define SCART_IN2_DA  5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define SCART_MONO    6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define SCART_MUTE    7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define SCART_DSP_IN  0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define SCART1_OUT    1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define SCART2_OUT    2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define OPMODE_AUTO       -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define OPMODE_MANUAL      0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define OPMODE_AUTODETECT  1   /* use autodetect (>= msp3410 only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define OPMODE_AUTOSELECT  2   /* use autodetect & autoselect (>= msp34xxG)   */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /* module parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) extern int msp_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) extern bool msp_once;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) extern bool msp_amsound;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) extern int msp_standard;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) extern bool msp_dolby;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) extern int msp_stereo_thresh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) enum msp3400_pads {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	MSP3400_PAD_IF_INPUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	MSP3400_PAD_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	MSP3400_NUM_PADS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) struct msp_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct v4l2_subdev sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct v4l2_ctrl_handler hdl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int rev1, rev2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	int ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u8 has_nicam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	u8 has_radio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	u8 has_headphones;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	u8 has_ntsc_jp_d_k3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u8 has_scart2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	u8 has_scart3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	u8 has_scart4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u8 has_scart2_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	u8 has_scart2_out_volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	u8 has_i2s_conf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	u8 has_subwoofer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	u8 has_sound_processing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	u8 has_virtual_dolby_surround;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	u8 has_dolby_pro_logic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u8 force_btsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	int radio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	int opmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	int std;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	v4l2_std_id v4l2_std, detected_std;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	int nicam_on;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int acb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	int in_scart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	int i2s_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int main, second;	/* sound carrier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	int input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	u32 route_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	u32 route_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	/* v4l2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	int audmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	int rxsubchans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		/* volume cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		struct v4l2_ctrl *volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		struct v4l2_ctrl *muted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	int scan_in_progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	/* thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct task_struct   *kthread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	wait_queue_head_t    wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	unsigned int         restart:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	unsigned int         watch_stereo:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	struct media_pad pads[MSP3400_NUM_PADS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) static inline struct msp_state *to_state(struct v4l2_subdev *sd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	return container_of(sd, struct msp_state, sd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static inline struct msp_state *ctrl_to_state(struct v4l2_ctrl *ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	return container_of(ctrl->handler, struct msp_state, hdl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /* msp3400-driver.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int msp_write_dem(struct i2c_client *client, int addr, int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int msp_write_dsp(struct i2c_client *client, int addr, int val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int msp_read_dem(struct i2c_client *client, int addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) int msp_read_dsp(struct i2c_client *client, int addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) int msp_reset(struct i2c_client *client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) void msp_set_scart(struct i2c_client *client, int in, int out);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) void msp_update_volume(struct msp_state *state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) int msp_sleep(struct msp_state *state, int timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* msp3400-kthreads.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) const char *msp_standard_std_name(int std);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void msp_set_audmode(struct i2c_client *client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int msp_detect_stereo(struct i2c_client *client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) int msp3400c_thread(void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) int msp3410d_thread(void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int msp34xxg_thread(void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) void msp3400c_set_mode(struct i2c_client *client, int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #endif /* MSP3400_DRIVER_H */