pvrusb2-video-v4l.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. saa711x support that is available in the v4l available starting
  24. with linux 2.6.15.
  25. */
  26. #include "pvrusb2-video-v4l.h"
  27. #include "pvrusb2-hdw-internal.h"
  28. #include "pvrusb2-debug.h"
  29. #include <linux/videodev2.h>
  30. #include <media/v4l2-common.h>
  31. #include <media/saa7115.h>
  32. #include <linux/errno.h>
  33. #include <linux/slab.h>
  34. struct routing_scheme {
  35. const int *def;
  36. unsigned int cnt;
  37. };
  38. static const int routing_scheme0[] = {
  39. [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
  40. /* In radio mode, we mute the video, but point at one
  41. spot just to stay consistent */
  42. [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
  43. [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5,
  44. [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
  45. };
  46. static const struct routing_scheme routing_schemes[] = {
  47. [PVR2_ROUTING_SCHEME_HAUPPAUGE] = {
  48. .def = routing_scheme0,
  49. .cnt = ARRAY_SIZE(routing_scheme0),
  50. },
  51. };
  52. void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  53. {
  54. if (hdw->input_dirty || hdw->force_dirty) {
  55. struct v4l2_routing route;
  56. const struct routing_scheme *sp;
  57. unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  58. pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
  59. hdw->input_val);
  60. if ((sid < ARRAY_SIZE(routing_schemes)) &&
  61. ((sp = routing_schemes + sid) != NULL) &&
  62. (hdw->input_val >= 0) &&
  63. (hdw->input_val < sp->cnt)) {
  64. route.input = sp->def[hdw->input_val];
  65. } else {
  66. pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  67. "*** WARNING *** subdev v4l2 set_input:"
  68. " Invalid routing scheme (%u)"
  69. " and/or input (%d)",
  70. sid, hdw->input_val);
  71. return;
  72. }
  73. route.output = 0;
  74. sd->ops->video->s_routing(sd, &route);
  75. }
  76. }
  77. /*
  78. Stuff for Emacs to see, in order to encourage consistent editing style:
  79. *** Local Variables: ***
  80. *** mode: c ***
  81. *** fill-column: 70 ***
  82. *** tab-width: 8 ***
  83. *** c-basic-offset: 8 ***
  84. *** End: ***
  85. */