Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *
0004  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
0005  *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
0006  */
0007 
0008 /*
0009 
0010    This source file is specifically designed to interface with the
0011    saa711x support that is available in the v4l available starting
0012    with linux 2.6.15.
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     /* In radio mode, we mute the video, but point at one
0036        spot just to stay consistent */
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, /* or SVIDEO0, it seems */
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 }