msp3400-driver.h 3.5 KB

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