pvrusb2-cs53l32a.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Copyright (C) 2005 Mike Isely <[email protected]>
  5. * Copyright (C) 2004 Aurelien Alleaume <[email protected]>
  6. */
  7. /*
  8. This source file is specifically designed to interface with the
  9. v4l-dvb cs53l32a module.
  10. */
  11. #include "pvrusb2-cs53l32a.h"
  12. #include "pvrusb2-hdw-internal.h"
  13. #include "pvrusb2-debug.h"
  14. #include <linux/videodev2.h>
  15. #include <media/v4l2-common.h>
  16. #include <linux/errno.h>
  17. struct routing_scheme {
  18. const int *def;
  19. unsigned int cnt;
  20. };
  21. static const int routing_scheme1[] = {
  22. [PVR2_CVAL_INPUT_TV] = 2, /* 1 or 2 seems to work here */
  23. [PVR2_CVAL_INPUT_RADIO] = 2,
  24. [PVR2_CVAL_INPUT_COMPOSITE] = 0,
  25. [PVR2_CVAL_INPUT_SVIDEO] = 0,
  26. };
  27. static const struct routing_scheme routing_def1 = {
  28. .def = routing_scheme1,
  29. .cnt = ARRAY_SIZE(routing_scheme1),
  30. };
  31. static const struct routing_scheme *routing_schemes[] = {
  32. [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
  33. };
  34. void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  35. {
  36. if (hdw->input_dirty || hdw->force_dirty) {
  37. const struct routing_scheme *sp;
  38. unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  39. u32 input;
  40. pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
  41. hdw->input_val);
  42. sp = (sid < ARRAY_SIZE(routing_schemes)) ?
  43. routing_schemes[sid] : NULL;
  44. if ((sp == NULL) ||
  45. (hdw->input_val < 0) ||
  46. (hdw->input_val >= sp->cnt)) {
  47. pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  48. "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
  49. sid, hdw->input_val);
  50. return;
  51. }
  52. input = sp->def[hdw->input_val];
  53. sd->ops->audio->s_routing(sd, input, 0, 0);
  54. }
  55. }