ivtv-audio.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Audio-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-audio.h"
  21. #include <media/msp3400.h>
  22. /* Selects the audio input and output according to the current
  23. settings. */
  24. int ivtv_audio_set_io(struct ivtv *itv)
  25. {
  26. struct v4l2_routing route;
  27. u32 audio_input;
  28. int mux_input;
  29. /* Determine which input to use */
  30. if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
  31. audio_input = itv->card->radio_input.audio_input;
  32. mux_input = itv->card->radio_input.muxer_input;
  33. } else {
  34. audio_input = itv->card->audio_inputs[itv->audio_input].audio_input;
  35. mux_input = itv->card->audio_inputs[itv->audio_input].muxer_input;
  36. }
  37. /* handle muxer chips */
  38. route.input = mux_input;
  39. route.output = 0;
  40. ivtv_i2c_hw(itv, itv->card->hw_muxer, VIDIOC_INT_S_AUDIO_ROUTING, &route);
  41. route.input = audio_input;
  42. if (itv->card->hw_audio & IVTV_HW_MSP34XX) {
  43. route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
  44. }
  45. return ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, &route);
  46. }
  47. void ivtv_audio_set_route(struct ivtv *itv, struct v4l2_routing *route)
  48. {
  49. ivtv_i2c_hw(itv, itv->card->hw_audio, VIDIOC_INT_S_AUDIO_ROUTING, route);
  50. }
  51. void ivtv_audio_set_audio_clock_freq(struct ivtv *itv, u8 freq)
  52. {
  53. static u32 freqs[3] = { 44100, 48000, 32000 };
  54. /* The audio clock of the digitizer must match the codec sample
  55. rate otherwise you get some very strange effects. */
  56. if (freq > 2)
  57. return;
  58. ivtv_call_i2c_clients(itv, VIDIOC_INT_AUDIO_CLOCK_FREQ, &freqs[freq]);
  59. }