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    v4l-dvb cs53l32a module.
0012 
0013 */
0014 
0015 #include "pvrusb2-cs53l32a.h"
0016 
0017 
0018 #include "pvrusb2-hdw-internal.h"
0019 #include "pvrusb2-debug.h"
0020 #include <linux/videodev2.h>
0021 #include <media/v4l2-common.h>
0022 #include <linux/errno.h>
0023 
0024 struct routing_scheme {
0025     const int *def;
0026     unsigned int cnt;
0027 };
0028 
0029 
0030 static const int routing_scheme1[] = {
0031     [PVR2_CVAL_INPUT_TV] = 2,  /* 1 or 2 seems to work here */
0032     [PVR2_CVAL_INPUT_RADIO] = 2,
0033     [PVR2_CVAL_INPUT_COMPOSITE] = 0,
0034     [PVR2_CVAL_INPUT_SVIDEO] =  0,
0035 };
0036 
0037 static const struct routing_scheme routing_def1 = {
0038     .def = routing_scheme1,
0039     .cnt = ARRAY_SIZE(routing_scheme1),
0040 };
0041 
0042 static const struct routing_scheme *routing_schemes[] = {
0043     [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
0044 };
0045 
0046 
0047 void pvr2_cs53l32a_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
0048 {
0049     if (hdw->input_dirty || hdw->force_dirty) {
0050         const struct routing_scheme *sp;
0051         unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
0052         u32 input;
0053         pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
0054                hdw->input_val);
0055         sp = (sid < ARRAY_SIZE(routing_schemes)) ?
0056             routing_schemes[sid] : NULL;
0057         if ((sp == NULL) ||
0058             (hdw->input_val < 0) ||
0059             (hdw->input_val >= sp->cnt)) {
0060             pvr2_trace(PVR2_TRACE_ERROR_LEGS,
0061                    "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
0062                    sid, hdw->input_val);
0063             return;
0064         }
0065         input = sp->def[hdw->input_val];
0066         sd->ops->audio->s_routing(sd, input, 0, 0);
0067     }
0068 }