pvrusb2-cs53l32a.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /*
  18. This source file is specifically designed to interface with the
  19. v4l-dvb cs53l32a module.
  20. */
  21. #include "pvrusb2-cs53l32a.h"
  22. #include "pvrusb2-hdw-internal.h"
  23. #include "pvrusb2-debug.h"
  24. #include <linux/videodev2.h>
  25. #include <media/v4l2-common.h>
  26. #include <linux/errno.h>
  27. struct routing_scheme {
  28. const int *def;
  29. unsigned int cnt;
  30. };
  31. static const int routing_scheme1[] = {
  32. [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */
  33. [PVR2_CVAL_INPUT_RADIO] = 2,
  34. [PVR2_CVAL_INPUT_COMPOSITE] = 0,
  35. [PVR2_CVAL_INPUT_SVIDEO] = 0,
  36. };
  37. static const struct routing_scheme routing_def1 = {
  38. .def = routing_scheme1,
  39. .cnt = ARRAY_SIZE(routing_scheme1),
  40. };
  41. static const struct routing_scheme *routing_schemes[] = {
  42. [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
  43. };
  44. void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  45. {
  46. if (hdw->input_dirty || hdw->force_dirty) {
  47. const struct routing_scheme *sp;
  48. unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  49. u32 input;
  50. pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
  51. hdw->input_val);
  52. sp = (sid < ARRAY_SIZE(routing_schemes)) ?
  53. routing_schemes[sid] : NULL;
  54. if ((sp == NULL) ||
  55. (hdw->input_val < 0) ||
  56. (hdw->input_val >= sp->cnt)) {
  57. pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  58. "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
  59. sid, hdw->input_val);
  60. return;
  61. }
  62. input = sp->def[hdw->input_val];
  63. sd->ops->audio->s_routing(sd, input, 0, 0);
  64. }
  65. }