linux/drivers/media/usb/pvrusb2/pvrusb2-audio.c
<<
>>
Prefs
   1/*
   2 *
   3 *
   4 *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
   5 *  Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
   6 *
   7 *  This program is free software; you can redistribute it and/or modify
   8 *  it under the terms of the GNU General Public License as published by
   9 *  the Free Software Foundation; either version 2 of the License
  10 *
  11 *  This program is distributed in the hope that it will be useful,
  12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 *  GNU General Public License for more details.
  15 *
  16 */
  17
  18#include "pvrusb2-audio.h"
  19#include "pvrusb2-hdw-internal.h"
  20#include "pvrusb2-debug.h"
  21#include <linux/videodev2.h>
  22#include <media/drv-intf/msp3400.h>
  23#include <media/v4l2-common.h>
  24
  25
  26struct routing_scheme {
  27        const int *def;
  28        unsigned int cnt;
  29};
  30
  31static const int routing_scheme0[] = {
  32        [PVR2_CVAL_INPUT_TV]        = MSP_INPUT_DEFAULT,
  33        [PVR2_CVAL_INPUT_RADIO]     = MSP_INPUT(MSP_IN_SCART2,
  34                                                MSP_IN_TUNER1,
  35                                                MSP_DSP_IN_SCART,
  36                                                MSP_DSP_IN_SCART),
  37        [PVR2_CVAL_INPUT_COMPOSITE] = MSP_INPUT(MSP_IN_SCART1,
  38                                                MSP_IN_TUNER1,
  39                                                MSP_DSP_IN_SCART,
  40                                                MSP_DSP_IN_SCART),
  41        [PVR2_CVAL_INPUT_SVIDEO]    = MSP_INPUT(MSP_IN_SCART1,
  42                                                MSP_IN_TUNER1,
  43                                                MSP_DSP_IN_SCART,
  44                                                MSP_DSP_IN_SCART),
  45};
  46
  47static const struct routing_scheme routing_def0 = {
  48        .def = routing_scheme0,
  49        .cnt = ARRAY_SIZE(routing_scheme0),
  50};
  51
  52static const struct routing_scheme *routing_schemes[] = {
  53        [PVR2_ROUTING_SCHEME_HAUPPAUGE] = &routing_def0,
  54};
  55
  56void pvr2_msp3400_subdev_update(struct pvr2_hdw *hdw, struct v4l2_subdev *sd)
  57{
  58        if (hdw->input_dirty || hdw->force_dirty) {
  59                const struct routing_scheme *sp;
  60                unsigned int sid = hdw->hdw_desc->signal_routing_scheme;
  61                u32 input;
  62
  63                pvr2_trace(PVR2_TRACE_CHIPS, "subdev msp3400 v4l2 set_stereo");
  64                sp = (sid < ARRAY_SIZE(routing_schemes)) ?
  65                        routing_schemes[sid] : NULL;
  66
  67                if ((sp != NULL) &&
  68                    (hdw->input_val >= 0) &&
  69                    (hdw->input_val < sp->cnt)) {
  70                        input = sp->def[hdw->input_val];
  71                } else {
  72                        pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  73                                   "*** WARNING *** subdev msp3400 set_input: Invalid routing scheme (%u) and/or input (%d)",
  74                                   sid, hdw->input_val);
  75                        return;
  76                }
  77                sd->ops->audio->s_routing(sd, input,
  78                        MSP_OUTPUT(MSP_SC_IN_DSP_SCART1), 0);
  79        }
  80}
  81