msp3400-driver.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. enum msp3400_pads {
  46. MSP3400_PAD_IF_INPUT,
  47. MSP3400_PAD_OUT,
  48. MSP3400_NUM_PADS
  49. };
  50. struct msp_state {
  51. struct v4l2_subdev sd;
  52. struct v4l2_ctrl_handler hdl;
  53. int rev1, rev2;
  54. int ident;
  55. u8 has_nicam;
  56. u8 has_radio;
  57. u8 has_headphones;
  58. u8 has_ntsc_jp_d_k3;
  59. u8 has_scart2;
  60. u8 has_scart3;
  61. u8 has_scart4;
  62. u8 has_scart2_out;
  63. u8 has_scart2_out_volume;
  64. u8 has_i2s_conf;
  65. u8 has_subwoofer;
  66. u8 has_sound_processing;
  67. u8 has_virtual_dolby_surround;
  68. u8 has_dolby_pro_logic;
  69. u8 force_btsc;
  70. int radio;
  71. int opmode;
  72. int std;
  73. int mode;
  74. v4l2_std_id v4l2_std, detected_std;
  75. int nicam_on;
  76. int acb;
  77. int in_scart;
  78. int i2s_mode;
  79. int main, second; /* sound carrier */
  80. int input;
  81. u32 route_in;
  82. u32 route_out;
  83. /* v4l2 */
  84. int audmode;
  85. int rxsubchans;
  86. struct {
  87. /* volume cluster */
  88. struct v4l2_ctrl *volume;
  89. struct v4l2_ctrl *muted;
  90. };
  91. int scan_in_progress;
  92. /* thread */
  93. struct task_struct *kthread;
  94. wait_queue_head_t wq;
  95. unsigned int restart:1;
  96. unsigned int watch_stereo:1;
  97. #if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
  98. struct media_pad pads[MSP3400_NUM_PADS];
  99. #endif
  100. };
  101. static inline struct msp_state *to_state(struct v4l2_subdev *sd)
  102. {
  103. return container_of(sd, struct msp_state, sd);
  104. }
  105. static inline struct msp_state *ctrl_to_state(struct v4l2_ctrl *ctrl)
  106. {
  107. return container_of(ctrl->handler, struct msp_state, hdl);
  108. }
  109. /* msp3400-driver.c */
  110. int msp_write_dem(struct i2c_client *client, int addr, int val);
  111. int msp_write_dsp(struct i2c_client *client, int addr, int val);
  112. int msp_read_dem(struct i2c_client *client, int addr);
  113. int msp_read_dsp(struct i2c_client *client, int addr);
  114. int msp_reset(struct i2c_client *client);
  115. void msp_set_scart(struct i2c_client *client, int in, int out);
  116. void msp_update_volume(struct msp_state *state);
  117. int msp_sleep(struct msp_state *state, int timeout);
  118. /* msp3400-kthreads.c */
  119. const char *msp_standard_std_name(int std);
  120. void msp_set_audmode(struct i2c_client *client);
  121. int msp_detect_stereo(struct i2c_client *client);
  122. int msp3400c_thread(void *data);
  123. int msp3410d_thread(void *data);
  124. int msp34xxg_thread(void *data);
  125. void msp3400c_set_mode(struct i2c_client *client, int mode);
  126. void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
  127. #endif /* MSP3400_DRIVER_H */