0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "pvrusb2-video-v4l.h"
0017
0018
0019
0020 #include "pvrusb2-hdw-internal.h"
0021 #include "pvrusb2-debug.h"
0022 #include <linux/videodev2.h>
0023 #include <media/v4l2-common.h>
0024 #include <media/i2c/saa7115.h>
0025 #include <linux/errno.h>
0026
0027 struct routing_scheme {
0028 const int *def;
0029 unsigned int cnt;
0030 };
0031
0032
0033 static const int routing_scheme0[] = {
0034 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
0035
0036
0037 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
0038 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5,
0039 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
0040 };
0041
0042 static const struct routing_scheme routing_def0 = {
0043 .def = routing_scheme0,
0044 .cnt = ARRAY_SIZE(routing_scheme0),
0045 };
0046
0047 static const int routing_scheme1[] = {
0048 [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
0049 [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
0050 [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE3,
0051 [PVR2_CVAL_INPUT_SVIDEO] = SAA7115_SVIDEO2,
0052 };
0053
0054 static const struct routing_scheme routing_def1 = {
0055 .def = routing_scheme1,
0056 .cnt = ARRAY_SIZE(routing_scheme1),
0057 };
0058
0059 static const struct routing_scheme *routing_schemes[] = {
0060 [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
0061 [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
0062 };
0063
0064 void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
0065 {
0066 if (hdw->input_dirty || hdw->force_dirty) {
0067 const struct routing_scheme *sp;
0068 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
0069 u32 input;
0070
0071 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
0072 hdw->input_val);
0073
0074 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
0075 routing_schemes[sid] : NULL;
0076 if ((sp == NULL) ||
0077 (hdw->input_val < 0) ||
0078 (hdw->input_val >= sp->cnt)) {
0079 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
0080 "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
0081 sid, hdw->input_val);
0082 return;
0083 }
0084 input = sp->def[hdw->input_val];
0085 sd->ops->video->s_routing(sd, input, 0, 0);
0086 }
0087 }