ivtv-routing.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Audio/video-routing-related ivtv functions.
  3. Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com>
  4. Copyright (C) 2005-2007 Hans Verkuil <hverkuil@xs4all.nl>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include "ivtv-driver.h"
  18. #include "ivtv-i2c.h"
  19. #include "ivtv-cards.h"
  20. #include "ivtv-gpio.h"
  21. #include "ivtv-routing.h"
  22. #include <media/msp3400.h>
  23. #include <media/m52790.h>
  24. #include <media/upd64031a.h>
  25. #include <media/upd64083.h>
  26. /* Selects the audio input and output according to the current
  27. settings. */
  28. void ivtv_audio_set_io(struct ivtv *itv)
  29. {
  30. const struct ivtv_card_audio_input *in;
  31. u32 input, output = 0;
  32. /* Determine which input to use */
  33. if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags))
  34. in = &itv->card->radio_input;
  35. else
  36. in = &itv->card->audio_inputs[itv->audio_input];
  37. /* handle muxer chips */
  38. input = in->muxer_input;
  39. if (itv->card->hw_muxer & IVTV_HW_M52790)
  40. output = M52790_OUT_STEREO;
  41. v4l2_subdev_call(itv->sd_muxer, audio, s_routing,
  42. input, output, 0);
  43. input = in->audio_input;
  44. output = 0;
  45. if (itv->card->hw_audio & IVTV_HW_MSP34XX)
  46. output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
  47. ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing,
  48. input, output, 0);
  49. }
  50. /* Selects the video input and output according to the current
  51. settings. */
  52. void ivtv_video_set_io(struct ivtv *itv)
  53. {
  54. int inp = itv->active_input;
  55. u32 input;
  56. u32 type;
  57. v4l2_subdev_call(itv->sd_video, video, s_routing,
  58. itv->card->video_inputs[inp].video_input, 0, 0);
  59. type = itv->card->video_inputs[inp].video_type;
  60. if (type == IVTV_CARD_INPUT_VID_TUNER) {
  61. input = 0; /* Tuner */
  62. } else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
  63. input = 2; /* S-Video */
  64. } else {
  65. input = 1; /* Composite */
  66. }
  67. if (itv->card->hw_video & IVTV_HW_GPIO)
  68. ivtv_call_hw(itv, IVTV_HW_GPIO, video, s_routing,
  69. input, 0, 0);
  70. if (itv->card->hw_video & IVTV_HW_UPD64031A) {
  71. if (type == IVTV_CARD_INPUT_VID_TUNER ||
  72. type >= IVTV_CARD_INPUT_COMPOSITE1) {
  73. /* Composite: GR on, connect to 3DYCS */
  74. input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
  75. } else {
  76. /* S-Video: GR bypassed, turn it off */
  77. input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
  78. }
  79. input |= itv->card->gr_config;
  80. ivtv_call_hw(itv, IVTV_HW_UPD64031A, video, s_routing,
  81. input, 0, 0);
  82. }
  83. if (itv->card->hw_video & IVTV_HW_UPD6408X) {
  84. input = UPD64083_YCS_MODE;
  85. if (type > IVTV_CARD_INPUT_VID_TUNER &&
  86. type < IVTV_CARD_INPUT_COMPOSITE1) {
  87. /* S-Video uses YCNR mode and internal Y-ADC, the
  88. upd64031a is not used. */
  89. input |= UPD64083_YCNR_MODE;
  90. }
  91. else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
  92. /* Use upd64031a output for tuner and
  93. composite(CX23416GYC only) inputs */
  94. if (type == IVTV_CARD_INPUT_VID_TUNER ||
  95. itv->card->type == IVTV_CARD_CX23416GYC) {
  96. input |= UPD64083_EXT_Y_ADC;
  97. }
  98. }
  99. ivtv_call_hw(itv, IVTV_HW_UPD6408X, video, s_routing,
  100. input, 0, 0);
  101. }
  102. }