root/drivers/media/usb/pvrusb2/pvrusb2-video-v4l.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pvr2_saa7115_subdev_update

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  *
   4  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
   5  *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
   6  */
   7 
   8 /*
   9 
  10    This source file is specifically designed to interface with the
  11    saa711x support that is available in the v4l available starting
  12    with linux 2.6.15.
  13 
  14 */
  15 
  16 #include "pvrusb2-video-v4l.h"
  17 
  18 
  19 
  20 #include "pvrusb2-hdw-internal.h"
  21 #include "pvrusb2-debug.h"
  22 #include <linux/videodev2.h>
  23 #include <media/v4l2-common.h>
  24 #include <media/i2c/saa7115.h>
  25 #include <linux/errno.h>
  26 
  27 struct routing_scheme {
  28         const int *def;
  29         unsigned int cnt;
  30 };
  31 
  32 
  33 static const int routing_scheme0[] = {
  34         [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
  35         /* In radio mode, we mute the video, but point at one
  36            spot just to stay consistent */
  37         [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
  38         [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE5,
  39         [PVR2_CVAL_INPUT_SVIDEO] =  SAA7115_SVIDEO2,
  40 };
  41 
  42 static const struct routing_scheme routing_def0 = {
  43         .def = routing_scheme0,
  44         .cnt = ARRAY_SIZE(routing_scheme0),
  45 };
  46 
  47 static const int routing_scheme1[] = {
  48         [PVR2_CVAL_INPUT_TV] = SAA7115_COMPOSITE4,
  49         [PVR2_CVAL_INPUT_RADIO] = SAA7115_COMPOSITE5,
  50         [PVR2_CVAL_INPUT_COMPOSITE] = SAA7115_COMPOSITE3,
  51         [PVR2_CVAL_INPUT_SVIDEO] =  SAA7115_SVIDEO2, /* or SVIDEO0, it seems */
  52 };
  53 
  54 static const struct routing_scheme routing_def1 = {
  55         .def = routing_scheme1,
  56         .cnt = ARRAY_SIZE(routing_scheme1),
  57 };
  58 
  59 static const struct routing_scheme *routing_schemes[] = {
  60         [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
  61         [PVR2_ROUTING_SCHEME_ONAIR] = &routing_def1,
  62 };
  63 
  64 void pvr2_saa7115_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  65 {
  66         if (hdw->input_dirty || hdw->force_dirty) {
  67                 const struct routing_scheme *sp;
  68                 unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  69                 u32 input;
  70 
  71                 pvr2_trace(PVR2_TRACE_CHIPS, "subdev v4l2 set_input(%d)",
  72                            hdw->input_val);
  73 
  74                 sp = (sid < ARRAY_SIZE(routing_schemes)) ?
  75                         routing_schemes[sid] : NULL;
  76                 if ((sp == NULL) ||
  77                     (hdw->input_val < 0) ||
  78                     (hdw->input_val >= sp->cnt)) {
  79                         pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  80                                    "*** WARNING *** subdev v4l2 set_input: Invalid routing scheme (%u) and/or input (%d)",
  81                                    sid, hdw->input_val);
  82                         return;
  83                 }
  84                 input = sp->def[hdw->input_val];
  85                 sd->ops->video->s_routing(sd, input, 0, 0);
  86         }
  87 }

/* [<][>][^][v][top][bottom][index][help] */