ivtv-routing.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. struct v4l2_routing route;
  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. route.input = in->muxer_input;
  39. route.output = 0;
  40. if (itv->card->hw_muxer & IVTV_HW_M52790)
  41. route.output = M52790_OUT_STEREO;
  42. ivtv_i2c_hw(itv, itv->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route);
  43. route.input = in->audio_input;
  44. route.output = 0;
  45. if (itv->card->hw_audio & IVTV_HW_MSP34XX)
  46. route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
  47. ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, &route);
  48. }
  49. /* Selects the video input and output according to the current
  50. settings. */
  51. void ivtv_video_set_io(struct ivtv *itv)
  52. {
  53. struct v4l2_routing route;
  54. int inp = itv->active_input;
  55. u32 type;
  56. route.input = itv->card->video_inputs[inp].video_input;
  57. route.output = 0;
  58. itv->video_dec_func(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
  59. type = itv->card->video_inputs[inp].video_type;
  60. if (type == IVTV_CARD_INPUT_VID_TUNER) {
  61. route.input = 0; /* Tuner */
  62. } else if (type < IVTV_CARD_INPUT_COMPOSITE1) {
  63. route.input = 2; /* S-Video */
  64. } else {
  65. route.input = 1; /* Composite */
  66. }
  67. if (itv->card->hw_video & IVTV_HW_GPIO)
  68. ivtv_gpio(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
  69. if (itv->card->hw_video & IVTV_HW_UPD64031A) {
  70. if (type == IVTV_CARD_INPUT_VID_TUNER ||
  71. type >= IVTV_CARD_INPUT_COMPOSITE1) {
  72. /* Composite: GR on, connect to 3DYCS */
  73. route.input = UPD64031A_GR_ON | UPD64031A_3DYCS_COMPOSITE;
  74. } else {
  75. /* S-Video: GR bypassed, turn it off */
  76. route.input = UPD64031A_GR_OFF | UPD64031A_3DYCS_DISABLE;
  77. }
  78. route.input |= itv->card->gr_config;
  79. ivtv_upd64031a(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
  80. }
  81. if (itv->card->hw_video & IVTV_HW_UPD6408X) {
  82. route.input = UPD64083_YCS_MODE;
  83. if (type > IVTV_CARD_INPUT_VID_TUNER &&
  84. type < IVTV_CARD_INPUT_COMPOSITE1) {
  85. /* S-Video uses YCNR mode and internal Y-ADC, the upd64031a
  86. is not used. */
  87. route.input |= UPD64083_YCNR_MODE;
  88. }
  89. else if (itv->card->hw_video & IVTV_HW_UPD64031A) {
  90. /* Use upd64031a output for tuner and composite(CX23416GYC only) inputs */
  91. if ((type == IVTV_CARD_INPUT_VID_TUNER)||
  92. (itv->card->type == IVTV_CARD_CX23416GYC)) {
  93. route.input |= UPD64083_EXT_Y_ADC;
  94. }
  95. }
  96. ivtv_upd64083(itv, VIDIOC_INT_S_VIDEO_ROUTING, &route);
  97. }
  98. }