Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /* Common methods for dibusb-based-receivers.
0003  *
0004  * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
0005  *
0006  * see Documentation/driver-api/media/drivers/dvb-usb.rst for more information
0007  */
0008 
0009 #include "dibusb.h"
0010 
0011 MODULE_LICENSE("GPL");
0012 
0013 /* 3000MC/P stuff */
0014 // Config Adjacent channels  Perf -cal22
0015 static struct dibx000_agc_config dib3000p_mt2060_agc_config = {
0016     .band_caps = BAND_VHF | BAND_UHF,
0017     .setup     = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
0018 
0019     .agc1_max = 48497,
0020     .agc1_min = 23593,
0021     .agc2_max = 46531,
0022     .agc2_min = 24904,
0023 
0024     .agc1_pt1 = 0x65,
0025     .agc1_pt2 = 0x69,
0026 
0027     .agc1_slope1 = 0x51,
0028     .agc1_slope2 = 0x27,
0029 
0030     .agc2_pt1 = 0,
0031     .agc2_pt2 = 0x33,
0032 
0033     .agc2_slope1 = 0x35,
0034     .agc2_slope2 = 0x37,
0035 };
0036 
0037 static struct dib3000mc_config stk3000p_dib3000p_config = {
0038     &dib3000p_mt2060_agc_config,
0039 
0040     .max_time     = 0x196,
0041     .ln_adc_level = 0x1cc7,
0042 
0043     .output_mpeg2_in_188_bytes = 1,
0044 
0045     .agc_command1 = 1,
0046     .agc_command2 = 1,
0047 };
0048 
0049 static struct dibx000_agc_config dib3000p_panasonic_agc_config = {
0050     .band_caps = BAND_VHF | BAND_UHF,
0051     .setup     = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
0052 
0053     .agc1_max = 56361,
0054     .agc1_min = 22282,
0055     .agc2_max = 47841,
0056     .agc2_min = 36045,
0057 
0058     .agc1_pt1 = 0x3b,
0059     .agc1_pt2 = 0x6b,
0060 
0061     .agc1_slope1 = 0x55,
0062     .agc1_slope2 = 0x1d,
0063 
0064     .agc2_pt1 = 0,
0065     .agc2_pt2 = 0x0a,
0066 
0067     .agc2_slope1 = 0x95,
0068     .agc2_slope2 = 0x1e,
0069 };
0070 
0071 static struct dib3000mc_config mod3000p_dib3000p_config = {
0072     &dib3000p_panasonic_agc_config,
0073 
0074     .max_time     = 0x51,
0075     .ln_adc_level = 0x1cc7,
0076 
0077     .output_mpeg2_in_188_bytes = 1,
0078 
0079     .agc_command1 = 1,
0080     .agc_command2 = 1,
0081 };
0082 
0083 int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap)
0084 {
0085     if (le16_to_cpu(adap->dev->udev->descriptor.idVendor) == USB_VID_LITEON &&
0086         le16_to_cpu(adap->dev->udev->descriptor.idProduct) ==
0087             USB_PID_LITEON_DVB_T_WARM) {
0088         msleep(1000);
0089     }
0090 
0091     adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach,
0092                      &adap->dev->i2c_adap,
0093                      DEFAULT_DIB3000P_I2C_ADDRESS,
0094                      &mod3000p_dib3000p_config);
0095     if ((adap->fe_adap[0].fe) == NULL)
0096         adap->fe_adap[0].fe = dvb_attach(dib3000mc_attach,
0097                          &adap->dev->i2c_adap,
0098                          DEFAULT_DIB3000MC_I2C_ADDRESS,
0099                          &mod3000p_dib3000p_config);
0100     if ((adap->fe_adap[0].fe) != NULL) {
0101         if (adap->priv != NULL) {
0102             struct dibusb_state *st = adap->priv;
0103             st->ops.pid_parse = dib3000mc_pid_parse;
0104             st->ops.pid_ctrl  = dib3000mc_pid_control;
0105         }
0106         return 0;
0107     }
0108     return -ENODEV;
0109 }
0110 EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach);
0111 
0112 static struct mt2060_config stk3000p_mt2060_config = {
0113     0x60
0114 };
0115 
0116 int dibusb_dib3000mc_tuner_attach(struct dvb_usb_adapter *adap)
0117 {
0118     struct dibusb_state *st = adap->priv;
0119     u8 a,b;
0120     u16 if1 = 1220;
0121     struct i2c_adapter *tun_i2c;
0122 
0123     // First IF calibration for Liteon Sticks
0124     if (le16_to_cpu(adap->dev->udev->descriptor.idVendor) == USB_VID_LITEON &&
0125         le16_to_cpu(adap->dev->udev->descriptor.idProduct) == USB_PID_LITEON_DVB_T_WARM) {
0126 
0127         dibusb_read_eeprom_byte(adap->dev,0x7E,&a);
0128         dibusb_read_eeprom_byte(adap->dev,0x7F,&b);
0129 
0130         if (a == 0x00)
0131             if1 += b;
0132         else if (a == 0x80)
0133             if1 -= b;
0134         else
0135             warn("LITE-ON DVB-T: Strange IF1 calibration :%2X %2X\n", a, b);
0136 
0137     } else if (le16_to_cpu(adap->dev->udev->descriptor.idVendor) == USB_VID_DIBCOM &&
0138            le16_to_cpu(adap->dev->udev->descriptor.idProduct) == USB_PID_DIBCOM_MOD3001_WARM) {
0139         u8 desc;
0140         dibusb_read_eeprom_byte(adap->dev, 7, &desc);
0141         if (desc == 2) {
0142             a = 127;
0143             do {
0144                 dibusb_read_eeprom_byte(adap->dev, a, &desc);
0145                 a--;
0146             } while (a > 7 && (desc == 0xff || desc == 0x00));
0147             if (desc & 0x80)
0148                 if1 -= (0xff - desc);
0149             else
0150                 if1 += desc;
0151         }
0152     }
0153 
0154     tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe_adap[0].fe, 1);
0155     if (dvb_attach(mt2060_attach, adap->fe_adap[0].fe, tun_i2c, &stk3000p_mt2060_config, if1) == NULL) {
0156         /* not found - use panasonic pll parameters */
0157         if (dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, 0x60, tun_i2c, DVB_PLL_ENV57H1XD5) == NULL)
0158             return -ENOMEM;
0159     } else {
0160         st->mt2060_present = 1;
0161         /* set the correct parameters for the dib3000p */
0162         dib3000mc_set_config(adap->fe_adap[0].fe, &stk3000p_dib3000p_config);
0163     }
0164     return 0;
0165 }
0166 EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);