linux/drivers/media/dvb-frontends/stb6100_proc.h
<<
>>
Prefs
   1/*
   2        STB6100 Silicon Tuner wrapper
   3        Copyright (C)2009 Igor M. Liplianin (liplianin@me.by)
   4
   5        This program is free software; you can redistribute it and/or modify
   6        it under the terms of the GNU General Public License as published by
   7        the Free Software Foundation; either version 2 of the License, or
   8        (at your option) any later version.
   9
  10        This program is distributed in the hope that it will be useful,
  11        but WITHOUT ANY WARRANTY; without even the implied warranty of
  12        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13        GNU General Public License for more details.
  14
  15        You should have received a copy of the GNU General Public License
  16        along with this program; if not, write to the Free Software
  17        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18*/
  19
  20static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
  21{
  22        struct dvb_frontend_ops *frontend_ops = &fe->ops;
  23        struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
  24        struct tuner_state      state;
  25        int err = 0;
  26
  27        if (tuner_ops->get_state) {
  28                if (frontend_ops->i2c_gate_ctrl)
  29                        frontend_ops->i2c_gate_ctrl(fe, 1);
  30
  31                err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &state);
  32                if (err < 0) {
  33                        printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  34                        return err;
  35                }
  36
  37                if (frontend_ops->i2c_gate_ctrl)
  38                        frontend_ops->i2c_gate_ctrl(fe, 0);
  39
  40                *frequency = state.frequency;
  41        }
  42
  43        return 0;
  44}
  45
  46static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
  47{
  48        struct dvb_frontend_ops *frontend_ops = &fe->ops;
  49        struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
  50        struct tuner_state      state;
  51        int err = 0;
  52
  53        state.frequency = frequency;
  54
  55        if (tuner_ops->set_state) {
  56                if (frontend_ops->i2c_gate_ctrl)
  57                        frontend_ops->i2c_gate_ctrl(fe, 1);
  58
  59                err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &state);
  60                if (err < 0) {
  61                        printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  62                        return err;
  63                }
  64
  65                if (frontend_ops->i2c_gate_ctrl)
  66                        frontend_ops->i2c_gate_ctrl(fe, 0);
  67
  68        }
  69
  70        return 0;
  71}
  72
  73static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
  74{
  75        struct dvb_frontend_ops *frontend_ops = &fe->ops;
  76        struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
  77        struct tuner_state      state;
  78        int err = 0;
  79
  80        if (tuner_ops->get_state) {
  81                if (frontend_ops->i2c_gate_ctrl)
  82                        frontend_ops->i2c_gate_ctrl(fe, 1);
  83
  84                err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &state);
  85                if (err < 0) {
  86                        printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  87                        return err;
  88                }
  89
  90                if (frontend_ops->i2c_gate_ctrl)
  91                        frontend_ops->i2c_gate_ctrl(fe, 0);
  92
  93                *bandwidth = state.bandwidth;
  94        }
  95
  96        return 0;
  97}
  98
  99static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
 100{
 101        struct dvb_frontend_ops *frontend_ops = &fe->ops;
 102        struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
 103        struct tuner_state      state;
 104        int err = 0;
 105
 106        state.bandwidth = bandwidth;
 107
 108        if (tuner_ops->set_state) {
 109                if (frontend_ops->i2c_gate_ctrl)
 110                        frontend_ops->i2c_gate_ctrl(fe, 1);
 111
 112                err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &state);
 113                if (err < 0) {
 114                        printk(KERN_ERR "%s: Invalid parameter\n", __func__);
 115                        return err;
 116                }
 117
 118                if (frontend_ops->i2c_gate_ctrl)
 119                        frontend_ops->i2c_gate_ctrl(fe, 0);
 120
 121        }
 122
 123        return 0;
 124}
 125