ivtv-routing.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. Audio/video-routing-related ivtv functions.
  4. Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
  5. Copyright (C) 2005-2007 Hans Verkuil <[email protected]>
  6. */
  7. #include "ivtv-driver.h"
  8. #include "ivtv-i2c.h"
  9. #include "ivtv-cards.h"
  10. #include "ivtv-gpio.h"
  11. #include "ivtv-routing.h"
  12. #include <media/drv-intf/msp3400.h>
  13. #include <media/i2c/m52790.h>
  14. #include <media/i2c/upd64031a.h>
  15. #include <media/i2c/upd64083.h>
  16. /* Selects the audio input and output according to the current
  17. settings. */
  18. void ivtv_audio_set_io(struct ivtv *itv)
  19. {
  20. const struct ivtv_card_audio_input *in;
  21. u32 input, output = 0;
  22. /* Determine which input to use */
  23. if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
  24. in = &itv->card->radio_input;
  25. else
  26. in = &itv->card->audio_inputs[itv->audio_input];
  27. /* handle muxer chips */
  28. input = in->muxer_input;
  29. if (itv->card->hw_muxer & IVTV_HW_M52790)
  30. output = M52790_OUT_STEREO;
  31. v4l2_subdev_call(itv->sd_muxer, audio, s_routing,
  32. input, output, 0);
  33. input = in->audio_input;
  34. output = 0;
  35. if (itv->card->hw_audio & IVTV_HW_MSP34XX)
  36. output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
  37. ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,
  38. input, output, 0);
  39. }
  40. /* Selects the video input and output according to the current
  41. settings. */
  42. void ivtv_video_set_io(struct ivtv *itv)
  43. {
  44. int inp = itv->active_input;
  45. u32 input;
  46. u32 type;
  47. v4l2_subdev_call(itv->sd_video, video, s_routing,
  48. itv->card->video_inputs[inp].video_input, 0, 0);
  49. type = itv->card->video_inputs[inp].video_type;
  50. if (type == IVTV_CARD_INPUT_VID_TUNER) {
  51. input = 0; /* Tuner */
  52. } else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
  53. input = 2; /* S-Video */
  54. } else {
  55. input = 1; /* Composite */
  56. }
  57. if (itv->card->hw_video & IVTV_HW_GPIO)
  58. ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing,
  59. input, 0, 0);
  60. if (itv->card->hw_video & IVTV_HW_UPD64031A) {
  61. if (type == IVTV_CARD_INPUT_VID_TUNER ||
  62. type >= IVTV_CARD_INPUT_COMPOSITE1) {
  63. /* Composite: GR on, connect to 3DYCS */
  64. input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
  65. } else {
  66. /* S-Video: GR bypassed, turn it off */
  67. input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
  68. }
  69. input |= itv->card->gr_config;
  70. ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing,
  71. input, 0, 0);
  72. }
  73. if (itv->card->hw_video & IVTV_HW_UPD6408X) {
  74. input = UPD64083_YCS_MODE;
  75. if (type > IVTV_CARD_INPUT_VID_TUNER &&
  76. type < IVTV_CARD_INPUT_COMPOSITE1) {
  77. /* S-Video uses YCNR mode and internal Y-ADC, the
  78. upd64031a is not used. */
  79. input |= UPD64083_YCNR_MODE;
  80. }
  81. else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
  82. /* Use upd64031a output for tuner and
  83. composite(CX23416GYC only) inputs */
  84. if (type == IVTV_CARD_INPUT_VID_TUNER ||
  85. itv->card->type == IVTV_CARD_CX23416GYC) {
  86. input |= UPD64083_EXT_Y_ADC;
  87. }
  88. }
  89. ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing,
  90. input, 0, 0);
  91. }
  92. }