msp3400-driver.h 3.5 KB

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