hwrng: core - Don't use a stack buffer in add_early_randomness()
[linux/fpc-iii.git] / drivers / media / usb / dvb-usb / dibusb-mc-common.c
blobd66f56cc46a580f1f56494676931ab182d14910d
1 /* Common methods for dibusb-based-receivers.
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation, version 2.
9 * see Documentation/dvb/README.dvb-usb for more information
12 #include <linux/kconfig.h>
13 #include "dibusb.h"
15 /* 3000MC/P stuff */
16 // Config Adjacent channels Perf -cal22
17 static struct dibx000_agc_config dib3000p_mt2060_agc_config = {
18 .band_caps = BAND_VHF | BAND_UHF,
19 .setup = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
21 .agc1_max = 48497,
22 .agc1_min = 23593,
23 .agc2_max = 46531,
24 .agc2_min = 24904,
26 .agc1_pt1 = 0x65,
27 .agc1_pt2 = 0x69,
29 .agc1_slope1 = 0x51,
30 .agc1_slope2 = 0x27,
32 .agc2_pt1 = 0,
33 .agc2_pt2 = 0x33,
35 .agc2_slope1 = 0x35,
36 .agc2_slope2 = 0x37,
39 static struct dib3000mc_config stk3000p_dib3000p_config = {
40 &dib3000p_mt2060_agc_config,
42 .max_time = 0x196,
43 .ln_adc_level = 0x1cc7,
45 .output_mpeg2_in_188_bytes = 1,
47 .agc_command1 = 1,
48 .agc_command2 = 1,
51 static struct dibx000_agc_config dib3000p_panasonic_agc_config = {
52 .band_caps = BAND_VHF | BAND_UHF,
53 .setup = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
55 .agc1_max = 56361,
56 .agc1_min = 22282,
57 .agc2_max = 47841,
58 .agc2_min = 36045,
60 .agc1_pt1 = 0x3b,
61 .agc1_pt2 = 0x6b,
63 .agc1_slope1 = 0x55,
64 .agc1_slope2 = 0x1d,
66 .agc2_pt1 = 0,
67 .agc2_pt2 = 0x0a,
69 .agc2_slope1 = 0x95,
70 .agc2_slope2 = 0x1e,
73 static struct dib3000mc_config mod3000p_dib3000p_config = {
74 &dib3000p_panasonic_agc_config,
76 .max_time = 0x51,
77 .ln_adc_level = 0x1cc7,
79 .output_mpeg2_in_188_bytes = 1,
81 .agc_command1 = 1,
82 .agc_command2 = 1,
85 int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap)
87 if (le16_to_cpu(adap->dev->udev->descriptor.idVendor) == USB_VID_LITEON &&
88 le16_to_cpu(adap->dev->udev->descriptor.idProduct) ==
89 USB_PID_LITEON_DVB_T_WARM) {
90 msleep(1000);
93 adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach,
94 &adap->dev->i2c_adap,
95 DEFAULT_DIB3000P_I2C_ADDRESS,
96 &mod3000p_dib3000p_config);
97 if ((adap->fe_adap[0].fe) == NULL)
98 adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach,
99 &adap->dev->i2c_adap,
100 DEFAULT_DIB3000MC_I2C_ADDRESS,
101 &mod3000p_dib3000p_config);
102 if ((adap->fe_adap[0].fe) != NULL) {
103 if (adap->priv != NULL) {
104 struct dibusb_state *st = adap->priv;
105 st->ops.pid_parse = dib3000mc_pid_parse;
106 st->ops.pid_ctrl = dib3000mc_pid_control;
108 return 0;
110 return -ENODEV;
112 EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach);
114 static struct mt2060_config stk3000p_mt2060_config = {
115 0x60
118 int dibusb_dib3000mc_tuner_attach(struct dvb_usb_adapter *adap)
120 struct dibusb_state *st = adap->priv;
121 u8 a,b;
122 u16 if1 = 1220;
123 struct i2c_adapter *tun_i2c;
125 // First IF calibration for Liteon Sticks
126 if (le16_to_cpu(adap->dev->udev->descriptor.idVendor) == USB_VID_LITEON &&
127 le16_to_cpu(adap->dev->udev->descriptor.idProduct) == USB_PID_LITEON_DVB_T_WARM) {
129 dibusb_read_eeprom_byte(adap->dev,0x7E,&a);
130 dibusb_read_eeprom_byte(adap->dev,0x7F,&b);
132 if (a == 0x00)
133 if1 += b;
134 else if (a == 0x80)
135 if1 -= b;
136 else
137 warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b);
139 } else if (le16_to_cpu(adap->dev->udev->descriptor.idVendor) == USB_VID_DIBCOM &&
140 le16_to_cpu(adap->dev->udev->descriptor.idProduct) == USB_PID_DIBCOM_MOD3001_WARM) {
141 u8 desc;
142 dibusb_read_eeprom_byte(adap->dev, 7, &desc);
143 if (desc == 2) {
144 a = 127;
145 do {
146 dibusb_read_eeprom_byte(adap->dev, a, &desc);
147 a--;
148 } while (a > 7 && (desc == 0xff || desc == 0x00));
149 if (desc & 0x80)
150 if1 -= (0xff - desc);
151 else
152 if1 += desc;
156 tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
157 if (dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk3000p_mt2060_config, if1) == NULL) {
158 /* not found - use panasonic pll parameters */
159 if (dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, tun_i2c, DVB_PLL_ENV57H1XD5) == NULL)
160 return -ENOMEM;
161 } else {
162 st->mt2060_present = 1;
163 /* set the correct parameters for the dib3000p */
164 dib3000mc_set_config(adap->fe_adap[0].fe, &stk3000p_dib3000p_config);
166 return 0;
168 EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);