msp3400-driver.h 3.4 KB

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