pvrusb2-cs53l32a.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. /*
  22. This source file is specifically designed to interface with the
  23. v4l-dvb cs53l32a module.
  24. */
  25. #include "pvrusb2-cs53l32a.h"
  26. #include "pvrusb2-hdw-internal.h"
  27. #include "pvrusb2-debug.h"
  28. #include <linux/videodev2.h>
  29. #include <media/v4l2-common.h>
  30. #include <linux/errno.h>
  31. #include <linux/slab.h>
  32. struct routing_scheme {
  33. const int *def;
  34. unsigned int cnt;
  35. };
  36. static const int routing_scheme1[] = {
  37. [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */
  38. [PVR2_CVAL_INPUT_RADIO] = 2,
  39. [PVR2_CVAL_INPUT_COMPOSITE] = 0,
  40. [PVR2_CVAL_INPUT_SVIDEO] = 0,
  41. };
  42. static const struct routing_scheme routing_schemes[] = {
  43. [PVR2_ROUTING_SCHEME_ONAIR] = {
  44. .def = routing_scheme1,
  45. .cnt = ARRAY_SIZE(routing_scheme1),
  46. },
  47. };
  48. void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  49. {
  50. if (hdw->input_dirty || hdw->force_dirty) {
  51. const struct routing_scheme *sp;
  52. unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  53. u32 input;
  54. pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
  55. hdw->input_val);
  56. if ((sid < ARRAY_SIZE(routing_schemes)) &&
  57. ((sp = routing_schemes + sid) != NULL) &&
  58. (hdw->input_val >= 0) &&
  59. (hdw->input_val < sp->cnt)) {
  60. input = sp->def[hdw->input_val];
  61. } else {
  62. pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  63. "*** WARNING *** subdev v4l2 set_input:"
  64. " Invalid routing scheme (%u)"
  65. " and/or input (%d)",
  66. sid, hdw->input_val);
  67. return;
  68. }
  69. sd->ops->audio->s_routing(sd, input, 0, 0);
  70. }
  71. }
  72. /*
  73. Stuff for Emacs to see, in order to encourage consistent editing style:
  74. *** Local Variables: ***
  75. *** mode: c ***
  76. *** fill-column: 70 ***
  77. *** tab-width: 8 ***
  78. *** c-basic-offset: 8 ***
  79. *** End: ***
  80. */