pvrusb2-audio.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. *
  3. *
  4. * Copyright (C) 2005 Mike Isely <isely@pobox.com>
  5. * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include "pvrusb2-audio.h"
  18. #include "pvrusb2-hdw-internal.h"
  19. #include "pvrusb2-debug.h"
  20. #include <linux/videodev2.h>
  21. #include <media/drv-intf/msp3400.h>
  22. #include <media/v4l2-common.h>
  23. struct routing_scheme {
  24. const int *def;
  25. unsigned int cnt;
  26. };
  27. static const int routing_scheme0[] = {
  28. [PVR2_CVAL_INPUT_TV] = MSP_INPUT_DEFAULT,
  29. [PVR2_CVAL_INPUT_RADIO] = MSP_INPUT(MSP_IN_SCART2,
  30. MSP_IN_TUNER1,
  31. MSP_DSP_IN_SCART,
  32. MSP_DSP_IN_SCART),
  33. [PVR2_CVAL_INPUT_COMPOSITE] = MSP_INPUT(MSP_IN_SCART1,
  34. MSP_IN_TUNER1,
  35. MSP_DSP_IN_SCART,
  36. MSP_DSP_IN_SCART),
  37. [PVR2_CVAL_INPUT_SVIDEO] = MSP_INPUT(MSP_IN_SCART1,
  38. MSP_IN_TUNER1,
  39. MSP_DSP_IN_SCART,
  40. MSP_DSP_IN_SCART),
  41. };
  42. static const struct routing_scheme routing_def0 = {
  43. .def = routing_scheme0,
  44. .cnt = ARRAY_SIZE(routing_scheme0),
  45. };
  46. static const struct routing_scheme *routing_schemes[] = {
  47. [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
  48. };
  49. void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  50. {
  51. if (hdw->input_dirty || hdw->force_dirty) {
  52. const struct routing_scheme *sp;
  53. unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  54. u32 input;
  55. pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo");
  56. sp = (sid < ARRAY_SIZE(routing_schemes)) ?
  57. routing_schemes[sid] : NULL;
  58. if ((sp != NULL) &&
  59. (hdw->input_val >= 0) &&
  60. (hdw->input_val < sp->cnt)) {
  61. input = sp->def[hdw->input_val];
  62. } else {
  63. pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  64. "*** WARNING *** subdev msp3400 set_input: Invalid routing scheme (%u) and/or input (%d)",
  65. sid, hdw->input_val);
  66. return;
  67. }
  68. sd->ops->audio->s_routing(sd, input,
  69. MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0);
  70. }
  71. }