Commit af4e067e authored by Luca Olivetti's avatar Luca Olivetti Committed by Mauro Carvalho Chehab

V4L/DVB (5625): Add support for the AF9005 demodulator from Afatech

Signed-off-by: default avatarLuca Olivetti <luca@ventoso.org>
Signed-off-by: default avatarManu Abraham <abraham.manu@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 79d3a8be
......@@ -218,3 +218,19 @@ config DVB_USB_OPERA1
select DVB_STV0299 if !DVB_FE_CUSTOMISE
help
Say Y here to support the Opera DVB-S USB2.0 receiver.
config DVB_USB_AF9005
tristate "Afatech AF9005 DVB-T USB1.1 support"
depends on DVB_USB
select DVB_TUNER_MT2060 if !DVB_FE_CUSTOMISE
help
Say Y here to support the Afatech AF9005 based DVB-T USB1.1 receiver
and the TerraTec Cinergy T USB XE (Rev.1)
config DVB_USB_AF9005_REMOTE
tristate "Afatech AF9005 default remote control support"
depends on DVB_USB_AF9005
help
Say Y here to support the default remote control decoding for the
Afatech AF9005 based receiver.
......@@ -55,4 +55,10 @@ dvb-usb-opera-objs = opera1.o
obj-$(CONFIG_DVB_USB_OPERA1) += dvb-usb-opera.o
dvb-usb-af9005-objs = af9005.o af9005-fe.o
obj-$(CONFIG_DVB_USB_AF9005) += dvb-usb-af9005.o
dvb-usb-af9005-remote-objs = af9005-remote.o
obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o
EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
/* Frontend part of the Linux driver for the Afatech 9005
* USB1.1 DVB-T receiver.
*
* Copyright (C) 2007 Luca Olivetti (luca@ventoso.org)
*
* Thanks to Afatech who kindly provided information.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* see Documentation/dvb/README.dvb-usb for more information
*/
#include "af9005.h"
#include "af9005-script.h"
#include "mt2060.h"
#include "qt1010.h"
#include <asm/div64.h>
struct af9005_fe_state {
struct dvb_usb_device *d;
struct dvb_frontend *tuner;
fe_status_t stat;
/* retraining parameters */
u32 original_fcw;
u16 original_rf_top;
u16 original_if_top;
u16 original_if_min;
u16 original_aci0_if_top;
u16 original_aci1_if_top;
u16 original_aci0_if_min;
u8 original_if_unplug_th;
u8 original_rf_unplug_th;
u8 original_dtop_if_unplug_th;
u8 original_dtop_rf_unplug_th;
/* statistics */
u32 pre_vit_error_count;
u32 pre_vit_bit_count;
u32 ber;
u32 post_vit_error_count;
u32 post_vit_bit_count;
u32 unc;
u16 abort_count;
int opened;
int strong;
unsigned long next_status_check;
struct dvb_frontend frontend;
};
static int af9005_write_word_agc(struct dvb_usb_device *d, u16 reghi,
u16 reglo, u8 pos, u8 len, u16 value)
{
int ret;
u8 temp;
if ((ret = af9005_write_ofdm_register(d, reglo, (u8) (value & 0xff))))
return ret;
temp = (u8) ((value & 0x0300) >> 8);
return af9005_write_register_bits(d, reghi, pos, len,
(u8) ((value & 0x300) >> 8));
}
static int af9005_read_word_agc(struct dvb_usb_device *d, u16 reghi,
u16 reglo, u8 pos, u8 len, u16 * value)
{
int ret;
u8 temp0, temp1;
if ((ret = af9005_read_ofdm_register(d, reglo, &temp0)))
return ret;
if ((ret = af9005_read_ofdm_register(d, reghi, &temp1)))
return ret;
switch (pos) {
case 0:
*value = ((u16) (temp1 & 0x03) << 8) + (u16) temp0;
break;
case 2:
*value = ((u16) (temp1 & 0x0C) << 6) + (u16) temp0;
break;
case 4:
*value = ((u16) (temp1 & 0x30) << 4) + (u16) temp0;
break;
case 6:
*value = ((u16) (temp1 & 0xC0) << 2) + (u16) temp0;
break;
default:
err("invalid pos in read word agc");
return -EINVAL;
}
return 0;
}
static int af9005_is_fecmon_available(struct dvb_frontend *fe, int *available)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u8 temp;
*available = false;
ret = af9005_read_register_bits(state->d, xd_p_fec_vtb_rsd_mon_en,
fec_vtb_rsd_mon_en_pos,
fec_vtb_rsd_mon_en_len, &temp);
if (ret)
return ret;
if (temp & 1) {
ret =
af9005_read_register_bits(state->d,
xd_p_reg_ofsm_read_rbc_en,
reg_ofsm_read_rbc_en_pos,
reg_ofsm_read_rbc_en_len, &temp);
if (ret)
return ret;
if ((temp & 1) == 0)
*available = true;
}
return 0;
}
static int af9005_get_post_vit_err_cw_count(struct dvb_frontend *fe,
u32 * post_err_count,
u32 * post_cw_count,
u16 * abort_count)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u32 err_count;
u32 cw_count;
u8 temp, temp0, temp1, temp2;
u16 loc_abort_count;
*post_err_count = 0;
*post_cw_count = 0;
/* check if error bit count is ready */
ret =
af9005_read_register_bits(state->d, xd_r_fec_rsd_ber_rdy,
fec_rsd_ber_rdy_pos, fec_rsd_ber_rdy_len,
&temp);
if (ret)
return ret;
if (!temp) {
deb_info("rsd counter not ready\n");
return 100;
}
/* get abort count */
ret =
af9005_read_ofdm_register(state->d,
xd_r_fec_rsd_abort_packet_cnt_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d,
xd_r_fec_rsd_abort_packet_cnt_15_8,
&temp1);
if (ret)
return ret;
loc_abort_count = ((u16) temp1 << 8) + temp0;
/* get error count */
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_rsd_bit_err_cnt_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_rsd_bit_err_cnt_15_8,
&temp1);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_rsd_bit_err_cnt_23_16,
&temp2);
if (ret)
return ret;
err_count = ((u32) temp2 << 16) + ((u32) temp1 << 8) + temp0;
*post_err_count = err_count - (u32) loc_abort_count *8 * 8;
/* get RSD packet number */
ret =
af9005_read_ofdm_register(state->d, xd_p_fec_rsd_packet_unit_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_p_fec_rsd_packet_unit_15_8,
&temp1);
if (ret)
return ret;
cw_count = ((u32) temp1 << 8) + temp0;
if (cw_count == 0) {
err("wrong RSD packet count");
return -EIO;
}
deb_info("POST abort count %d err count %d rsd packets %d\n",
loc_abort_count, err_count, cw_count);
*post_cw_count = cw_count - (u32) loc_abort_count;
*abort_count = loc_abort_count;
return 0;
}
static int af9005_get_post_vit_ber(struct dvb_frontend *fe,
u32 * post_err_count, u32 * post_cw_count,
u16 * abort_count)
{
u32 loc_cw_count = 0, loc_err_count;
u16 loc_abort_count;
int ret;
ret =
af9005_get_post_vit_err_cw_count(fe, &loc_err_count, &loc_cw_count,
&loc_abort_count);
if (ret)
return ret;
*post_err_count = loc_err_count;
*post_cw_count = loc_cw_count * 204 * 8;
*abort_count = loc_abort_count;
return 0;
}
static int af9005_get_pre_vit_err_bit_count(struct dvb_frontend *fe,
u32 * pre_err_count,
u32 * pre_bit_count)
{
struct af9005_fe_state *state = fe->demodulator_priv;
u8 temp, temp0, temp1, temp2;
u32 super_frame_count, x, bits;
int ret;
ret =
af9005_read_register_bits(state->d, xd_r_fec_vtb_ber_rdy,
fec_vtb_ber_rdy_pos, fec_vtb_ber_rdy_len,
&temp);
if (ret)
return ret;
if (!temp) {
deb_info("viterbi counter not ready\n");
return 101; /* ERR_APO_VTB_COUNTER_NOT_READY; */
}
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_vtb_err_bit_cnt_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_vtb_err_bit_cnt_15_8,
&temp1);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_vtb_err_bit_cnt_23_16,
&temp2);
if (ret)
return ret;
*pre_err_count = ((u32) temp2 << 16) + ((u32) temp1 << 8) + temp0;
ret =
af9005_read_ofdm_register(state->d, xd_p_fec_super_frm_unit_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_p_fec_super_frm_unit_15_8,
&temp1);
if (ret)
return ret;
super_frame_count = ((u32) temp1 << 8) + temp0;
if (super_frame_count == 0) {
deb_info("super frame count 0\n");
return 102;
}
/* read fft mode */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_txmod,
reg_tpsd_txmod_pos, reg_tpsd_txmod_len,
&temp);
if (ret)
return ret;
if (temp == 0) {
/* 2K */
x = 1512;
} else if (temp == 1) {
/* 8k */
x = 6048;
} else {
err("Invalid fft mode");
return -EINVAL;
}
/* read constellation mode */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_const,
reg_tpsd_const_pos, reg_tpsd_const_len,
&temp);
if (ret)
return ret;
switch (temp) {
case 0: /* QPSK */
bits = 2;
break;
case 1: /* QAM_16 */
bits = 4;
break;
case 2: /* QAM_64 */
bits = 6;
break;
default:
err("invalid constellation mode");
return -EINVAL;
}
*pre_bit_count = super_frame_count * 68 * 4 * x * bits;
deb_info("PRE err count %d frame count %d bit count %d\n",
*pre_err_count, super_frame_count, *pre_bit_count);
return 0;
}
static int af9005_reset_pre_viterbi(struct dvb_frontend *fe)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
/* set super frame count to 1 */
ret =
af9005_write_ofdm_register(state->d, xd_p_fec_super_frm_unit_7_0,
1 & 0xff);
if (ret)
return ret;
af9005_write_ofdm_register(state->d, xd_p_fec_super_frm_unit_15_8,
1 >> 8);
if (ret)
return ret;
/* reset pre viterbi error count */
ret =
af9005_write_register_bits(state->d, xd_p_fec_vtb_ber_rst,
fec_vtb_ber_rst_pos, fec_vtb_ber_rst_len,
1);
return ret;
}
static int af9005_reset_post_viterbi(struct dvb_frontend *fe)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
/* set packet unit */
ret =
af9005_write_ofdm_register(state->d, xd_p_fec_rsd_packet_unit_7_0,
10000 & 0xff);
if (ret)
return ret;
ret =
af9005_write_ofdm_register(state->d, xd_p_fec_rsd_packet_unit_15_8,
10000 >> 8);
if (ret)
return ret;
/* reset post viterbi error count */
ret =
af9005_write_register_bits(state->d, xd_p_fec_rsd_ber_rst,
fec_rsd_ber_rst_pos, fec_rsd_ber_rst_len,
1);
return ret;
}
static int af9005_get_statistic(struct dvb_frontend *fe)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret, fecavailable;
u64 numerator, denominator;
deb_info("GET STATISTIC\n");
ret = af9005_is_fecmon_available(fe, &fecavailable);
if (ret)
return ret;
if (!fecavailable) {
deb_info("fecmon not available\n");
return 0;
}
ret = af9005_get_pre_vit_err_bit_count(fe, &state->pre_vit_error_count,
&state->pre_vit_bit_count);
if (ret == 0) {
af9005_reset_pre_viterbi(fe);
if (state->pre_vit_bit_count > 0) {
/* according to v 0.0.4 of the dvb api ber should be a multiple
of 10E-9 so we have to multiply the error count by
10E9=1000000000 */
numerator =
(u64) state->pre_vit_error_count * (u64) 1000000000;
denominator = (u64) state->pre_vit_bit_count;
state->ber = do_div(numerator, denominator);
} else {
state->ber = 0xffffffff;
}
}
ret = af9005_get_post_vit_ber(fe, &state->post_vit_error_count,
&state->post_vit_bit_count,
&state->abort_count);
if (ret == 0) {
ret = af9005_reset_post_viterbi(fe);
state->unc += state->abort_count;
if (ret)
return ret;
}
return 0;
}
static int af9005_fe_refresh_state(struct dvb_frontend *fe)
{
struct af9005_fe_state *state = fe->demodulator_priv;
if (time_after(jiffies, state->next_status_check)) {
deb_info("REFRESH STATE\n");
/* statistics */
if (af9005_get_statistic(fe))
err("get_statistic_failed");
state->next_status_check = jiffies + 250 * HZ / 1000;
}
return 0;
}
static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat)
{
struct af9005_fe_state *state = fe->demodulator_priv;
u8 temp;
int ret;
if (state->tuner == NULL)
return -ENODEV;
*stat = 0;
ret = af9005_read_register_bits(state->d, xd_p_agc_lock,
agc_lock_pos, agc_lock_len, &temp);
if (ret)
return ret;
if (temp)
*stat |= FE_HAS_SIGNAL;
ret = af9005_read_register_bits(state->d, xd_p_fd_tpsd_lock,
fd_tpsd_lock_pos, fd_tpsd_lock_len,
&temp);
if (ret)
return ret;
if (temp)
*stat |= FE_HAS_CARRIER;
ret = af9005_read_register_bits(state->d,
xd_r_mp2if_sync_byte_locked,
mp2if_sync_byte_locked_pos,
mp2if_sync_byte_locked_pos, &temp);
if (ret)
return ret;
if (temp)
*stat |= FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_LOCK;
if (state->opened)
af9005_led_control(state->d, *stat & FE_HAS_LOCK);
ret =
af9005_read_register_bits(state->d, xd_p_reg_strong_sginal_detected,
reg_strong_sginal_detected_pos,
reg_strong_sginal_detected_len, &temp);
if (ret)
return ret;
if (temp != state->strong) {
deb_info("adjust for strong signal %d\n", temp);
state->strong = temp;
}
return 0;
}
static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber)
{
struct af9005_fe_state *state = fe->demodulator_priv;
if (state->tuner == NULL)
return -ENODEV;
af9005_fe_refresh_state(fe);
*ber = state->ber;
return 0;
}
static int af9005_fe_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
{
struct af9005_fe_state *state = fe->demodulator_priv;
if (state->tuner == NULL)
return -ENODEV;
af9005_fe_refresh_state(fe);
*unc = state->unc;
return 0;
}
static int af9005_fe_read_signal_strength(struct dvb_frontend *fe,
u16 * strength)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u8 if_gain, rf_gain;
if (state->tuner == NULL)
return -ENODEV;
ret =
af9005_read_ofdm_register(state->d, xd_r_reg_aagc_rf_gain,
&rf_gain);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_reg_aagc_if_gain,
&if_gain);
if (ret)
return ret;
/* this value has no real meaning, but i don't have the tables that relate
the rf and if gain with the dbm, so I just scale the value */
*strength = (512 - rf_gain - if_gain) << 7;
return 0;
}
static int af9005_fe_read_snr(struct dvb_frontend *fe, u16 * snr)
{
/* the snr can be derived from the ber and the constellation
but I don't think this kind of complex calculations belong
in the driver. I may be wrong.... */
return -ENOSYS;
}
static int af9005_fe_program_cfoe(struct dvb_usb_device *d, fe_bandwidth_t bw)
{
u8 temp0, temp1, temp2, temp3, buf[4];
int ret;
u32 NS_coeff1_2048Nu;
u32 NS_coeff1_8191Nu;
u32 NS_coeff1_8192Nu;
u32 NS_coeff1_8193Nu;
u32 NS_coeff2_2k;
u32 NS_coeff2_8k;
switch (bw) {
case BANDWIDTH_6_MHZ:
NS_coeff1_2048Nu = 0x2ADB6DC;
NS_coeff1_8191Nu = 0xAB7313;
NS_coeff1_8192Nu = 0xAB6DB7;
NS_coeff1_8193Nu = 0xAB685C;
NS_coeff2_2k = 0x156DB6E;
NS_coeff2_8k = 0x55B6DC;
break;
case BANDWIDTH_7_MHZ:
NS_coeff1_2048Nu = 0x3200001;
NS_coeff1_8191Nu = 0xC80640;
NS_coeff1_8192Nu = 0xC80000;
NS_coeff1_8193Nu = 0xC7F9C0;
NS_coeff2_2k = 0x1900000;
NS_coeff2_8k = 0x640000;
break;
case BANDWIDTH_8_MHZ:
NS_coeff1_2048Nu = 0x3924926;
NS_coeff1_8191Nu = 0xE4996E;
NS_coeff1_8192Nu = 0xE49249;
NS_coeff1_8193Nu = 0xE48B25;
NS_coeff2_2k = 0x1C92493;
NS_coeff2_8k = 0x724925;
break;
default:
err("Invalid bandwith %d.", bw);
return -EINVAL;
}
/*
* write NS_coeff1_2048Nu
*/
temp0 = (u8) (NS_coeff1_2048Nu & 0x000000FF);
temp1 = (u8) ((NS_coeff1_2048Nu & 0x0000FF00) >> 8);
temp2 = (u8) ((NS_coeff1_2048Nu & 0x00FF0000) >> 16);
temp3 = (u8) ((NS_coeff1_2048Nu & 0x03000000) >> 24);
/* big endian to make 8051 happy */
buf[0] = temp3;
buf[1] = temp2;
buf[2] = temp1;
buf[3] = temp0;
/* cfoe_NS_2k_coeff1_25_24 */
ret = af9005_write_ofdm_register(d, 0xAE00, buf[0]);
if (ret)
return ret;
/* cfoe_NS_2k_coeff1_23_16 */
ret = af9005_write_ofdm_register(d, 0xAE01, buf[1]);
if (ret)
return ret;
/* cfoe_NS_2k_coeff1_15_8 */
ret = af9005_write_ofdm_register(d, 0xAE02, buf[2]);
if (ret)
return ret;
/* cfoe_NS_2k_coeff1_7_0 */
ret = af9005_write_ofdm_register(d, 0xAE03, buf[3]);
if (ret)
return ret;
/*
* write NS_coeff2_2k
*/
temp0 = (u8) ((NS_coeff2_2k & 0x0000003F));
temp1 = (u8) ((NS_coeff2_2k & 0x00003FC0) >> 6);
temp2 = (u8) ((NS_coeff2_2k & 0x003FC000) >> 14);
temp3 = (u8) ((NS_coeff2_2k & 0x01C00000) >> 22);
/* big endian to make 8051 happy */
buf[0] = temp3;
buf[1] = temp2;
buf[2] = temp1;
buf[3] = temp0;
ret = af9005_write_ofdm_register(d, 0xAE04, buf[0]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE05, buf[1]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE06, buf[2]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE07, buf[3]);
if (ret)
return ret;
/*
* write NS_coeff1_8191Nu
*/
temp0 = (u8) ((NS_coeff1_8191Nu & 0x000000FF));
temp1 = (u8) ((NS_coeff1_8191Nu & 0x0000FF00) >> 8);
temp2 = (u8) ((NS_coeff1_8191Nu & 0x00FFC000) >> 16);
temp3 = (u8) ((NS_coeff1_8191Nu & 0x03000000) >> 24);
/* big endian to make 8051 happy */
buf[0] = temp3;
buf[1] = temp2;
buf[2] = temp1;
buf[3] = temp0;
ret = af9005_write_ofdm_register(d, 0xAE08, buf[0]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE09, buf[1]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE0A, buf[2]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE0B, buf[3]);
if (ret)
return ret;
/*
* write NS_coeff1_8192Nu
*/
temp0 = (u8) (NS_coeff1_8192Nu & 0x000000FF);
temp1 = (u8) ((NS_coeff1_8192Nu & 0x0000FF00) >> 8);
temp2 = (u8) ((NS_coeff1_8192Nu & 0x00FFC000) >> 16);
temp3 = (u8) ((NS_coeff1_8192Nu & 0x03000000) >> 24);
/* big endian to make 8051 happy */
buf[0] = temp3;
buf[1] = temp2;
buf[2] = temp1;
buf[3] = temp0;
ret = af9005_write_ofdm_register(d, 0xAE0C, buf[0]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE0D, buf[1]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE0E, buf[2]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE0F, buf[3]);
if (ret)
return ret;
/*
* write NS_coeff1_8193Nu
*/
temp0 = (u8) ((NS_coeff1_8193Nu & 0x000000FF));
temp1 = (u8) ((NS_coeff1_8193Nu & 0x0000FF00) >> 8);
temp2 = (u8) ((NS_coeff1_8193Nu & 0x00FFC000) >> 16);
temp3 = (u8) ((NS_coeff1_8193Nu & 0x03000000) >> 24);
/* big endian to make 8051 happy */
buf[0] = temp3;
buf[1] = temp2;
buf[2] = temp1;
buf[3] = temp0;
ret = af9005_write_ofdm_register(d, 0xAE10, buf[0]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE11, buf[1]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE12, buf[2]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE13, buf[3]);
if (ret)
return ret;
/*
* write NS_coeff2_8k
*/
temp0 = (u8) ((NS_coeff2_8k & 0x0000003F));
temp1 = (u8) ((NS_coeff2_8k & 0x00003FC0) >> 6);
temp2 = (u8) ((NS_coeff2_8k & 0x003FC000) >> 14);
temp3 = (u8) ((NS_coeff2_8k & 0x01C00000) >> 22);
/* big endian to make 8051 happy */
buf[0] = temp3;
buf[1] = temp2;
buf[2] = temp1;
buf[3] = temp0;
ret = af9005_write_ofdm_register(d, 0xAE14, buf[0]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE15, buf[1]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE16, buf[2]);
if (ret)
return ret;
ret = af9005_write_ofdm_register(d, 0xAE17, buf[3]);
return ret;
}
static int af9005_fe_select_bw(struct dvb_usb_device *d, fe_bandwidth_t bw)
{
u8 temp;
switch (bw) {
case BANDWIDTH_6_MHZ:
temp = 0;
break;
case BANDWIDTH_7_MHZ:
temp = 1;
break;
case BANDWIDTH_8_MHZ:
temp = 2;
break;
default:
err("Invalid bandwith %d.", bw);
return -EINVAL;
}
return af9005_write_register_bits(d, xd_g_reg_bw, reg_bw_pos,
reg_bw_len, temp);
}
static int af9005_fe_power(struct dvb_frontend *fe, int on)
{
struct af9005_fe_state *state = fe->demodulator_priv;
u8 temp = on;
int ret;
deb_info("power %s tuner\n", on ? "on" : "off");
ret = af9005_send_command(state->d, 0x03, &temp, 1, NULL, 0);
return ret;
}
static struct mt2060_config af9005_mt2060_config = {
0xC0
};
static struct qt1010_config af9005_qt1010_config = {
0xC4
};
static int af9005_fe_init(struct dvb_frontend *fe)
{
struct af9005_fe_state *state = fe->demodulator_priv;
struct dvb_usb_adapter *adap = fe->dvb->priv;
int ret, i, scriptlen;
u8 temp, temp0 = 0, temp1 = 0, temp2 = 0;
u8 buf[2];
u16 if1;
deb_info("in af9005_fe_init\n");
/* reset */
deb_info("reset\n");
if ((ret =
af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst_en,
4, 1, 0x01)))
return ret;
if ((ret = af9005_write_ofdm_register(state->d, APO_REG_RESET, 0)))
return ret;
/* clear ofdm reset */
deb_info("clear ofdm reset\n");
for (i = 0; i < 150; i++) {
if ((ret =
af9005_read_ofdm_register(state->d,
xd_I2C_reg_ofdm_rst, &temp)))
return ret;
if (temp & (regmask[reg_ofdm_rst_len - 1] << reg_ofdm_rst_pos))
break;
msleep(10);
}
if (i == 150)
return -ETIMEDOUT;
/*FIXME in the dump
write B200 A9
write xd_g_reg_ofsm_clk 7
read eepr c6 (2)
read eepr c7 (2)
misc ctrl 3 -> 1
read eepr ca (6)
write xd_g_reg_ofsm_clk 0
write B200 a1
*/
ret = af9005_write_ofdm_register(state->d, 0xb200, 0xa9);
if (ret)
return ret;
ret = af9005_write_ofdm_register(state->d, xd_g_reg_ofsm_clk, 0x07);
if (ret)
return ret;
temp = 0x01;
ret = af9005_send_command(state->d, 0x03, &temp, 1, NULL, 0);
if (ret)
return ret;
ret = af9005_write_ofdm_register(state->d, xd_g_reg_ofsm_clk, 0x00);
if (ret)
return ret;
ret = af9005_write_ofdm_register(state->d, 0xb200, 0xa1);
if (ret)
return ret;
temp = regmask[reg_ofdm_rst_len - 1] << reg_ofdm_rst_pos;
if ((ret =
af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst,
reg_ofdm_rst_pos, reg_ofdm_rst_len, 1)))
return ret;
if ((ret =
af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst,
reg_ofdm_rst_pos, reg_ofdm_rst_len, 0)))
return ret;
if (ret)
return ret;
/* don't know what register aefc is, but this is what the windows driver does */
ret = af9005_write_ofdm_register(state->d, 0xaefc, 0);
if (ret)
return ret;
/* set stand alone chip */
deb_info("set stand alone chip\n");
if ((ret =
af9005_write_register_bits(state->d, xd_p_reg_dca_stand_alone,
reg_dca_stand_alone_pos,
reg_dca_stand_alone_len, 1)))
return ret;
/* set dca upper & lower chip */
deb_info("set dca upper & lower chip\n");
if ((ret =
af9005_write_register_bits(state->d, xd_p_reg_dca_upper_chip,
reg_dca_upper_chip_pos,
reg_dca_upper_chip_len, 0)))
return ret;
if ((ret =
af9005_write_register_bits(state->d, xd_p_reg_dca_lower_chip,
reg_dca_lower_chip_pos,
reg_dca_lower_chip_len, 0)))
return ret;
/* set 2wire master clock to 0x14 (for 60KHz) */
deb_info("set 2wire master clock to 0x14 (for 60KHz)\n");
if ((ret =
af9005_write_ofdm_register(state->d, xd_I2C_i2c_m_period, 0x14)))
return ret;
/* clear dca enable chip */
deb_info("clear dca enable chip\n");
if ((ret =
af9005_write_register_bits(state->d, xd_p_reg_dca_en,
reg_dca_en_pos, reg_dca_en_len, 0)))
return ret;
/* FIXME these are register bits, but I don't know which ones */
ret = af9005_write_ofdm_register(state->d, 0xa16c, 1);
if (ret)
return ret;
ret = af9005_write_ofdm_register(state->d, 0xa3c1, 0);
if (ret)
return ret;
/* init other parameters: program cfoe and select bandwith */
deb_info("program cfoe\n");
if ((ret = af9005_fe_program_cfoe(state->d, BANDWIDTH_6_MHZ)))
return ret;
/* set read-update bit for constellation */
deb_info("set read-update bit for constellation\n");
if ((ret =
af9005_write_register_bits(state->d, xd_p_reg_feq_read_update,
reg_feq_read_update_pos,
reg_feq_read_update_len, 1)))
return ret;
/* sample code has a set MPEG TS code here
but sniffing reveals that it doesn't do it */
/* set read-update bit to 1 for DCA constellation */
deb_info("set read-update bit 1 for DCA constellation\n");
if ((ret =
af9005_write_register_bits(state->d, xd_p_reg_dca_read_update,
reg_dca_read_update_pos,
reg_dca_read_update_len, 1)))
return ret;
/* enable fec monitor */
deb_info("enable fec monitor\n");
if ((ret =
af9005_write_register_bits(state->d, xd_p_fec_vtb_rsd_mon_en,
fec_vtb_rsd_mon_en_pos,
fec_vtb_rsd_mon_en_len, 1)))
return ret;
/* FIXME should be register bits, I don't know which ones */
ret = af9005_write_ofdm_register(state->d, 0xa601, 0);
/* set api_retrain_never_freeze */
deb_info("set api_retrain_never_freeze\n");
if ((ret = af9005_write_ofdm_register(state->d, 0xaefb, 0x01)))
return ret;
/* load init script */
deb_info("load init script\n");
scriptlen = sizeof(script) / sizeof(RegDesc);
for (i = 0; i < scriptlen; i++) {
if ((ret =
af9005_write_register_bits(state->d, script[i].reg,
script[i].pos,
script[i].len, script[i].val)))
return ret;
/* save 3 bytes of original fcw */
if (script[i].reg == 0xae18)
temp2 = script[i].val;
if (script[i].reg == 0xae19)
temp1 = script[i].val;
if (script[i].reg == 0xae1a)
temp0 = script[i].val;
/* save original unplug threshold */
if (script[i].reg == xd_p_reg_unplug_th)
state->original_if_unplug_th = script[i].val;
if (script[i].reg == xd_p_reg_unplug_rf_gain_th)
state->original_rf_unplug_th = script[i].val;
if (script[i].reg == xd_p_reg_unplug_dtop_if_gain_th)
state->original_dtop_if_unplug_th = script[i].val;
if (script[i].reg == xd_p_reg_unplug_dtop_rf_gain_th)
state->original_dtop_rf_unplug_th = script[i].val;
}
state->original_fcw =
((u32) temp2 << 16) + ((u32) temp1 << 8) + (u32) temp0;
/* save original TOPs */
deb_info("save original TOPs\n");
/* RF TOP */
ret =
af9005_read_word_agc(state->d,
xd_p_reg_aagc_rf_top_numerator_9_8,
xd_p_reg_aagc_rf_top_numerator_7_0, 0, 2,
&state->original_rf_top);
if (ret)
return ret;
/* IF TOP */
ret =
af9005_read_word_agc(state->d,
xd_p_reg_aagc_if_top_numerator_9_8,
xd_p_reg_aagc_if_top_numerator_7_0, 0, 2,
&state->original_if_top);
if (ret)
return ret;
/* ACI 0 IF TOP */
ret =
af9005_read_word_agc(state->d, 0xA60E, 0xA60A, 4, 2,
&state->original_aci0_if_top);
if (ret)
return ret;
/* ACI 1 IF TOP */
ret =
af9005_read_word_agc(state->d, 0xA60E, 0xA60B, 6, 2,
&state->original_aci1_if_top);
if (ret)
return ret;
/* attach tuner and init */
if (state->tuner == NULL) {
/* read tuner and board id from eeprom */
ret = af9005_read_eeprom(adap->dev, 0xc6, buf, 2);
if (ret) {
err("Impossible to read EEPROM\n");
return ret;
}
deb_info("Tuner id %d, board id %d\n", buf[0], buf[1]);
switch (buf[0]) {
case 2: /* MT2060 */
/* read if1 from eeprom */
ret = af9005_read_eeprom(adap->dev, 0xc8, buf, 2);
if (ret) {
err("Impossible to read EEPROM\n");
return ret;
}
if1 = (u16) (buf[0] << 8) + buf[1];
state->tuner =
dvb_attach(mt2060_attach, fe, &adap->dev->i2c_adap,
&af9005_mt2060_config, if1);
if (state->tuner == NULL) {
deb_info("MT2060 attach failed\n");
return -ENODEV;
}
break;
case 3: /* QT1010 */
case 9: /* QT1010B */
state->tuner =
dvb_attach(qt1010_attach, fe, &adap->dev->i2c_adap,
&af9005_qt1010_config);
if (state->tuner == NULL) {
deb_info("QT1010 attach failed\n");
return -ENODEV;
}
break;
default:
err("Unsupported tuner type %d", buf[0]);
return -ENODEV;
}
ret = state->tuner->ops.tuner_ops.init(state->tuner);
if (ret)
return ret;
}
deb_info("profit!\n");
return 0;
}
static int af9005_fe_sleep(struct dvb_frontend *fe)
{
return af9005_fe_power(fe, 0);
}
static int af9005_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
{
struct af9005_fe_state *state = fe->demodulator_priv;
if (acquire) {
state->opened++;
} else {
state->opened--;
if (!state->opened)
af9005_led_control(state->d, 0);
}
return 0;
}
static int af9005_fe_set_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *fep)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u8 temp, temp0, temp1, temp2;
deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency,
fep->u.ofdm.bandwidth);
if (state->tuner == NULL) {
err("Tuner not attached");
return -ENODEV;
}
deb_info("turn off led\n");
/* not in the log */
ret = af9005_led_control(state->d, 0);
if (ret)
return ret;
/* not sure about the bits */
ret = af9005_write_register_bits(state->d, XD_MP2IF_MISC, 2, 1, 0);
if (ret)
return ret;
/* set FCW to default value */
deb_info("set FCW to default value\n");
temp0 = (u8) (state->original_fcw & 0x000000ff);
temp1 = (u8) ((state->original_fcw & 0x0000ff00) >> 8);
temp2 = (u8) ((state->original_fcw & 0x00ff0000) >> 16);
ret = af9005_write_ofdm_register(state->d, 0xae1a, temp0);
if (ret)
return ret;
ret = af9005_write_ofdm_register(state->d, 0xae19, temp1);
if (ret)
return ret;
ret = af9005_write_ofdm_register(state->d, 0xae18, temp2);
if (ret)
return ret;
/* restore original TOPs */
deb_info("restore original TOPs\n");
ret =
af9005_write_word_agc(state->d,
xd_p_reg_aagc_rf_top_numerator_9_8,
xd_p_reg_aagc_rf_top_numerator_7_0, 0, 2,
state->original_rf_top);
if (ret)
return ret;
ret =
af9005_write_word_agc(state->d,
xd_p_reg_aagc_if_top_numerator_9_8,
xd_p_reg_aagc_if_top_numerator_7_0, 0, 2,
state->original_if_top);
if (ret)
return ret;
ret =
af9005_write_word_agc(state->d, 0xA60E, 0xA60A, 4, 2,
state->original_aci0_if_top);
if (ret)
return ret;
ret =
af9005_write_word_agc(state->d, 0xA60E, 0xA60B, 6, 2,
state->original_aci1_if_top);
if (ret)
return ret;
/* select bandwith */
deb_info("select bandwidth");
ret = af9005_fe_select_bw(state->d, fep->u.ofdm.bandwidth);
if (ret)
return ret;
ret = af9005_fe_program_cfoe(state->d, fep->u.ofdm.bandwidth);
if (ret)
return ret;
/* clear easy mode flag */
deb_info("clear easy mode flag\n");
ret = af9005_write_ofdm_register(state->d, 0xaefd, 0);
if (ret)
return ret;
/* set unplug threshold to original value */
deb_info("set unplug threshold to original value\n");
ret =
af9005_write_ofdm_register(state->d, xd_p_reg_unplug_th,
state->original_if_unplug_th);
if (ret)
return ret;
/* set tuner */
deb_info("set tuner\n");
ret = state->tuner->ops.tuner_ops.set_params(state->tuner, fep);
if (ret)
return ret;
/* trigger ofsm */
deb_info("trigger ofsm\n");
temp = 0;
ret = af9005_write_tuner_registers(state->d, 0xffff, &temp, 1);
if (ret)
return ret;
/* clear retrain and freeze flag */
deb_info("clear retrain and freeze flag\n");
ret =
af9005_write_register_bits(state->d,
xd_p_reg_api_retrain_request,
reg_api_retrain_request_pos, 2, 0);
if (ret)
return ret;
/* reset pre viterbi and post viterbi registers and statistics */
af9005_reset_pre_viterbi(fe);
af9005_reset_post_viterbi(fe);
state->pre_vit_error_count = 0;
state->pre_vit_bit_count = 0;
state->ber = 0;
state->post_vit_error_count = 0;
/* state->unc = 0; commented out since it should be ever increasing */
state->abort_count = 0;
state->next_status_check = jiffies;
state->strong = -1;
return 0;
}
static int af9005_fe_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *fep)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u8 temp;
/* mode */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_const,
reg_tpsd_const_pos, reg_tpsd_const_len,
&temp);
if (ret)
return ret;
deb_info("===== fe_get_frontend ==============\n");
deb_info("CONSTELLATION ");
switch (temp) {
case 0:
fep->u.ofdm.constellation = QPSK;
deb_info("QPSK\n");
break;
case 1:
fep->u.ofdm.constellation = QAM_16;
deb_info("QAM_16\n");
break;
case 2:
fep->u.ofdm.constellation = QAM_64;
deb_info("QAM_64\n");
break;
}
/* tps hierarchy and alpha value */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_hier,
reg_tpsd_hier_pos, reg_tpsd_hier_len,
&temp);
if (ret)
return ret;
deb_info("HIERARCHY ");
switch (temp) {
case 0:
fep->u.ofdm.hierarchy_information = HIERARCHY_NONE;
deb_info("NONE\n");
break;
case 1:
fep->u.ofdm.hierarchy_information = HIERARCHY_1;
deb_info("1\n");
break;
case 2:
fep->u.ofdm.hierarchy_information = HIERARCHY_2;
deb_info("2\n");
break;
case 3:
fep->u.ofdm.hierarchy_information = HIERARCHY_4;
deb_info("4\n");
break;
}
/* high/low priority */
ret =
af9005_read_register_bits(state->d, xd_g_reg_dec_pri,
reg_dec_pri_pos, reg_dec_pri_len, &temp);
if (ret)
return ret;
/* if temp is set = high priority */
deb_info("PRIORITY %s\n", temp ? "high" : "low");
/* high coderate */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_hpcr,
reg_tpsd_hpcr_pos, reg_tpsd_hpcr_len,
&temp);
if (ret)
return ret;
deb_info("CODERATE HP ");
switch (temp) {
case 0:
fep->u.ofdm.code_rate_HP = FEC_1_2;
deb_info("FEC_1_2\n");
break;
case 1:
fep->u.ofdm.code_rate_HP = FEC_2_3;
deb_info("FEC_2_3\n");
break;
case 2:
fep->u.ofdm.code_rate_HP = FEC_3_4;
deb_info("FEC_3_4\n");
break;
case 3:
fep->u.ofdm.code_rate_HP = FEC_5_6;
deb_info("FEC_5_6\n");
break;
case 4:
fep->u.ofdm.code_rate_HP = FEC_7_8;
deb_info("FEC_7_8\n");
break;
}
/* low coderate */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_lpcr,
reg_tpsd_lpcr_pos, reg_tpsd_lpcr_len,
&temp);
if (ret)
return ret;
deb_info("CODERATE LP ");
switch (temp) {
case 0:
fep->u.ofdm.code_rate_LP = FEC_1_2;
deb_info("FEC_1_2\n");
break;
case 1:
fep->u.ofdm.code_rate_LP = FEC_2_3;
deb_info("FEC_2_3\n");
break;
case 2:
fep->u.ofdm.code_rate_LP = FEC_3_4;
deb_info("FEC_3_4\n");
break;
case 3:
fep->u.ofdm.code_rate_LP = FEC_5_6;
deb_info("FEC_5_6\n");
break;
case 4:
fep->u.ofdm.code_rate_LP = FEC_7_8;
deb_info("FEC_7_8\n");
break;
}
/* guard interval */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_gi,
reg_tpsd_gi_pos, reg_tpsd_gi_len, &temp);
if (ret)
return ret;
deb_info("GUARD INTERVAL ");
switch (temp) {
case 0:
fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
deb_info("1_32\n");
break;
case 1:
fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
deb_info("1_16\n");
break;
case 2:
fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
deb_info("1_8\n");
break;
case 3:
fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_4;
deb_info("1_4\n");
break;
}
/* fft */
ret =
af9005_read_register_bits(state->d, xd_g_reg_tpsd_txmod,
reg_tpsd_txmod_pos, reg_tpsd_txmod_len,
&temp);
if (ret)
return ret;
deb_info("TRANSMISSION MODE ");
switch (temp) {
case 0:
fep->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
deb_info("2K\n");
break;
case 1:
fep->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
deb_info("8K\n");
break;
}
/* bandwidth */
ret =
af9005_read_register_bits(state->d, xd_g_reg_bw, reg_bw_pos,
reg_bw_len, &temp);
deb_info("BANDWIDTH ");
switch (temp) {
case 0:
fep->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
deb_info("6\n");
break;
case 1:
fep->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
deb_info("7\n");
break;
case 2:
fep->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
deb_info("8\n");
break;
}
return 0;
}
static void af9005_fe_release(struct dvb_frontend *fe)
{
struct af9005_fe_state *state =
(struct af9005_fe_state *)fe->demodulator_priv;
if (state->tuner != NULL && state->tuner->ops.tuner_ops.release != NULL) {
state->tuner->ops.tuner_ops.release(state->tuner);
#ifdef CONFIG_DVB_CORE_ATTACH
symbol_put_addr(state->tuner->ops.tuner_ops.release);
#endif
}
kfree(state);
}
static struct dvb_frontend_ops af9005_fe_ops;
struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d)
{
struct af9005_fe_state *state = NULL;
/* allocate memory for the internal state */
state = kzalloc(sizeof(struct af9005_fe_state), GFP_KERNEL);
if (state == NULL)
goto error;
deb_info("attaching frontend af9005\n");
state->d = d;
state->tuner = NULL;
state->opened = 0;
memcpy(&state->frontend.ops, &af9005_fe_ops,
sizeof(struct dvb_frontend_ops));
state->frontend.demodulator_priv = state;
return &state->frontend;
error:
return NULL;
}
static struct dvb_frontend_ops af9005_fe_ops = {
.info = {
.name = "AF9005 USB DVB-T",
.type = FE_OFDM,
.frequency_min = 44250000,
.frequency_max = 867250000,
.frequency_stepsize = 250000,
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO |
FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_RECOVER |
FE_CAN_HIERARCHY_AUTO,
},
.release = af9005_fe_release,
.init = af9005_fe_init,
.sleep = af9005_fe_sleep,
.ts_bus_ctrl = af9005_ts_bus_ctrl,
.set_frontend = af9005_fe_set_frontend,
.get_frontend = af9005_fe_get_frontend,
.read_status = af9005_fe_read_status,
.read_ber = af9005_fe_read_ber,
.read_signal_strength = af9005_fe_read_signal_strength,
.read_snr = af9005_fe_read_snr,
.read_ucblocks = af9005_fe_read_unc_blocks,
};
/* DVB USB compliant Linux driver for the Afatech 9005
* USB1.1 DVB-T receiver.
*
* Standard remote decode function
*
* Copyright (C) 2007 Luca Olivetti (luca@ventoso.org)
*
* Thanks to Afatech who kindly provided information.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* see Documentation/dvb/REDME.dvb-usb for more information
*/
#include "af9005.h"
/* debug */
int dvb_usb_af9005_remote_debug;
module_param_named(debug, dvb_usb_af9005_remote_debug, int, 0644);
MODULE_PARM_DESC(debug,
"enable (1) or disable (0) debug messages."
DVB_USB_DEBUG_STATUS);
#define deb_decode(args...) dprintk(dvb_usb_af9005_remote_debug,0x01,args)
struct dvb_usb_rc_key af9005_rc_keys[] = {
{0x01, 0xb7, KEY_POWER},
{0x01, 0xa7, KEY_VOLUMEUP},
{0x01, 0x87, KEY_CHANNELUP},
{0x01, 0x7f, KEY_MUTE},
{0x01, 0xbf, KEY_VOLUMEDOWN},
{0x01, 0x3f, KEY_CHANNELDOWN},
{0x01, 0xdf, KEY_1},
{0x01, 0x5f, KEY_2},
{0x01, 0x9f, KEY_3},
{0x01, 0x1f, KEY_4},
{0x01, 0xef, KEY_5},
{0x01, 0x6f, KEY_6},
{0x01, 0xaf, KEY_7},
{0x01, 0x27, KEY_8},
{0x01, 0x07, KEY_9},
{0x01, 0xcf, KEY_ZOOM},
{0x01, 0x4f, KEY_0},
{0x01, 0x8f, KEY_GOTO}, /* marked jump on the remote */
{0x00, 0xbd, KEY_POWER},
{0x00, 0x7d, KEY_VOLUMEUP},
{0x00, 0xfd, KEY_CHANNELUP},
{0x00, 0x9d, KEY_MUTE},
{0x00, 0x5d, KEY_VOLUMEDOWN},
{0x00, 0xdd, KEY_CHANNELDOWN},
{0x00, 0xad, KEY_1},
{0x00, 0x6d, KEY_2},
{0x00, 0xed, KEY_3},
{0x00, 0x8d, KEY_4},
{0x00, 0x4d, KEY_5},
{0x00, 0xcd, KEY_6},
{0x00, 0xb5, KEY_7},
{0x00, 0x75, KEY_8},
{0x00, 0xf5, KEY_9},
{0x00, 0x95, KEY_ZOOM},
{0x00, 0x55, KEY_0},
{0x00, 0xd5, KEY_GOTO}, /* marked jump on the remote */
};
int af9005_rc_keys_size = ARRAY_SIZE(af9005_rc_keys);
static int repeatable_keys[] = {
KEY_VOLUMEUP,
KEY_VOLUMEDOWN,
KEY_CHANNELUP,
KEY_CHANNELDOWN
};
int af9005_rc_decode(struct dvb_usb_device *d, u8 * data, int len, u32 * event,
int *state)
{
u16 mark, space;
u32 result;
u8 cust, dat, invdat;
int i;
if (len >= 6) {
mark = (u16) (data[0] << 8) + data[1];
space = (u16) (data[2] << 8) + data[3];
if (space * 3 < mark) {
for (i = 0; i < ARRAY_SIZE(repeatable_keys); i++) {
if (d->last_event == repeatable_keys[i]) {
*state = REMOTE_KEY_REPEAT;
*event = d->last_event;
deb_decode("repeat key, event %x\n",
*event);
return 0;
}
}
deb_decode("repeated key ignored (non repeatable)\n");
return 0;
} else if (len >= 33 * 4) { /*32 bits + start code */
result = 0;
for (i = 4; i < 4 + 32 * 4; i += 4) {
result <<= 1;
mark = (u16) (data[i] << 8) + data[i + 1];
mark >>= 1;
space = (u16) (data[i + 2] << 8) + data[i + 3];
space >>= 1;
if (mark * 2 > space)
result += 1;
}
deb_decode("key pressed, raw value %x\n", result);
if ((result & 0xff000000) != 0xfe000000) {
deb_decode
("doesn't start with 0xfe, ignored\n");
return 0;
}
cust = (result >> 16) & 0xff;
dat = (result >> 8) & 0xff;
invdat = (~result) & 0xff;
if (dat != invdat) {
deb_decode("code != inverted code\n");
return 0;
}
for (i = 0; i < af9005_rc_keys_size; i++) {
if (af9005_rc_keys[i].custom == cust
&& af9005_rc_keys[i].data == dat) {
*event = af9005_rc_keys[i].event;
*state = REMOTE_KEY_PRESSED;
deb_decode
("key pressed, event %x\n", *event);
return 0;
}
}
deb_decode("not found in table\n");
}
}
return 0;
}
EXPORT_SYMBOL(af9005_rc_keys);
EXPORT_SYMBOL(af9005_rc_keys_size);
EXPORT_SYMBOL(af9005_rc_decode);
MODULE_AUTHOR("Luca Olivetti <luca@ventoso.org>");
MODULE_DESCRIPTION
("Standard remote control decoder for Afatech 9005 DVB-T USB1.1 stick");
MODULE_VERSION("1.0");
MODULE_LICENSE("GPL");
/*
File automatically generated by createinit.py using data
extracted from AF05BDA.sys (windows driver):
dd if=AF05BDA.sys of=initsequence bs=1 skip=88316 count=1110
python createinit.py > af9005-script.h
*/
typedef struct {
u16 reg;
u8 pos;
u8 len;
u8 val;
} RegDesc;
RegDesc script[] = {
{0xa180, 0x0, 0x8, 0xa},
{0xa181, 0x0, 0x8, 0xd7},
{0xa182, 0x0, 0x8, 0xa3},
{0xa0a0, 0x0, 0x8, 0x0},
{0xa0a1, 0x0, 0x5, 0x0},
{0xa0a1, 0x5, 0x1, 0x1},
{0xa0c0, 0x0, 0x4, 0x1},
{0xa20e, 0x4, 0x4, 0xa},
{0xa20f, 0x0, 0x8, 0x40},
{0xa210, 0x0, 0x8, 0x8},
{0xa32a, 0x0, 0x4, 0xa},
{0xa32c, 0x0, 0x8, 0x20},
{0xa32b, 0x0, 0x8, 0x15},
{0xa1a0, 0x1, 0x1, 0x1},
{0xa000, 0x0, 0x1, 0x1},
{0xa000, 0x1, 0x1, 0x0},
{0xa001, 0x1, 0x1, 0x1},
{0xa001, 0x0, 0x1, 0x0},
{0xa001, 0x5, 0x1, 0x0},
{0xa00e, 0x0, 0x5, 0x10},
{0xa00f, 0x0, 0x3, 0x4},
{0xa00f, 0x3, 0x3, 0x5},
{0xa010, 0x0, 0x3, 0x4},
{0xa010, 0x3, 0x3, 0x5},
{0xa016, 0x4, 0x4, 0x3},
{0xa01f, 0x0, 0x6, 0xa},
{0xa020, 0x0, 0x6, 0xa},
{0xa2bc, 0x0, 0x1, 0x1},
{0xa2bc, 0x5, 0x1, 0x1},
{0xa015, 0x0, 0x8, 0x50},
{0xa016, 0x0, 0x1, 0x0},
{0xa02a, 0x0, 0x8, 0x50},
{0xa029, 0x0, 0x8, 0x4b},
{0xa614, 0x0, 0x8, 0x46},
{0xa002, 0x0, 0x5, 0x19},
{0xa003, 0x0, 0x5, 0x1a},
{0xa004, 0x0, 0x5, 0x19},
{0xa005, 0x0, 0x5, 0x1a},
{0xa008, 0x0, 0x8, 0x69},
{0xa009, 0x0, 0x2, 0x2},
{0xae1b, 0x0, 0x8, 0x69},
{0xae1c, 0x0, 0x8, 0x2},
{0xae1d, 0x0, 0x8, 0x2a},
{0xa022, 0x0, 0x8, 0xaa},
{0xa006, 0x0, 0x8, 0xc8},
{0xa007, 0x0, 0x2, 0x0},
{0xa00c, 0x0, 0x8, 0xba},
{0xa00d, 0x0, 0x2, 0x2},
{0xa608, 0x0, 0x8, 0xba},
{0xa60e, 0x0, 0x2, 0x2},
{0xa609, 0x0, 0x8, 0x80},
{0xa60e, 0x2, 0x2, 0x3},
{0xa00a, 0x0, 0x8, 0xb6},
{0xa00b, 0x0, 0x2, 0x0},
{0xa011, 0x0, 0x8, 0xb9},
{0xa012, 0x0, 0x2, 0x0},
{0xa013, 0x0, 0x8, 0xbd},
{0xa014, 0x0, 0x2, 0x2},
{0xa366, 0x0, 0x1, 0x1},
{0xa2bc, 0x3, 0x1, 0x0},
{0xa2bd, 0x0, 0x8, 0xa},
{0xa2be, 0x0, 0x8, 0x14},
{0xa2bf, 0x0, 0x8, 0x8},
{0xa60a, 0x0, 0x8, 0xbd},
{0xa60e, 0x4, 0x2, 0x2},
{0xa60b, 0x0, 0x8, 0x86},
{0xa60e, 0x6, 0x2, 0x3},
{0xa001, 0x2, 0x2, 0x1},
{0xa1c7, 0x0, 0x8, 0xf5},
{0xa03d, 0x0, 0x8, 0xb1},
{0xa616, 0x0, 0x8, 0xff},
{0xa617, 0x0, 0x8, 0xad},
{0xa618, 0x0, 0x8, 0xad},
{0xa61e, 0x3, 0x1, 0x1},
{0xae1a, 0x0, 0x8, 0x0},
{0xae19, 0x0, 0x8, 0xc8},
{0xae18, 0x0, 0x8, 0x61},
{0xa140, 0x0, 0x8, 0x0},
{0xa141, 0x0, 0x8, 0xc8},
{0xa142, 0x0, 0x7, 0x61},
{0xa023, 0x0, 0x8, 0xff},
{0xa021, 0x0, 0x8, 0xad},
{0xa026, 0x0, 0x1, 0x0},
{0xa024, 0x0, 0x8, 0xff},
{0xa025, 0x0, 0x8, 0xff},
{0xa1c8, 0x0, 0x8, 0xf},
{0xa2bc, 0x1, 0x1, 0x0},
{0xa60c, 0x0, 0x4, 0x5},
{0xa60c, 0x4, 0x4, 0x6},
{0xa60d, 0x0, 0x8, 0xa},
{0xa371, 0x0, 0x1, 0x1},
{0xa366, 0x1, 0x3, 0x7},
{0xa338, 0x0, 0x8, 0x10},
{0xa339, 0x0, 0x6, 0x7},
{0xa33a, 0x0, 0x6, 0x1f},
{0xa33b, 0x0, 0x8, 0xf6},
{0xa33c, 0x3, 0x5, 0x4},
{0xa33d, 0x4, 0x4, 0x0},
{0xa33d, 0x1, 0x1, 0x1},
{0xa33d, 0x2, 0x1, 0x1},
{0xa33d, 0x3, 0x1, 0x1},
{0xa16d, 0x0, 0x4, 0xf},
{0xa161, 0x0, 0x5, 0x5},
{0xa162, 0x0, 0x4, 0x5},
{0xa165, 0x0, 0x8, 0xff},
{0xa166, 0x0, 0x8, 0x9c},
{0xa2c3, 0x0, 0x4, 0x5},
{0xa61a, 0x0, 0x6, 0xf},
{0xb200, 0x0, 0x8, 0xa1},
{0xb201, 0x0, 0x8, 0x7},
{0xa093, 0x0, 0x1, 0x0},
{0xa093, 0x1, 0x5, 0xf},
{0xa094, 0x0, 0x8, 0xff},
{0xa095, 0x0, 0x8, 0xf},
{0xa080, 0x2, 0x5, 0x3},
{0xa081, 0x0, 0x4, 0x0},
{0xa081, 0x4, 0x4, 0x9},
{0xa082, 0x0, 0x5, 0x1f},
{0xa08d, 0x0, 0x8, 0x1},
{0xa083, 0x0, 0x8, 0x32},
{0xa084, 0x0, 0x1, 0x0},
{0xa08e, 0x0, 0x8, 0x3},
{0xa085, 0x0, 0x8, 0x32},
{0xa086, 0x0, 0x3, 0x0},
{0xa087, 0x0, 0x8, 0x6e},
{0xa088, 0x0, 0x5, 0x15},
{0xa089, 0x0, 0x8, 0x0},
{0xa08a, 0x0, 0x5, 0x19},
{0xa08b, 0x0, 0x8, 0x92},
{0xa08c, 0x0, 0x5, 0x1c},
{0xa120, 0x0, 0x8, 0x0},
{0xa121, 0x0, 0x5, 0x10},
{0xa122, 0x0, 0x8, 0x0},
{0xa123, 0x0, 0x7, 0x40},
{0xa123, 0x7, 0x1, 0x0},
{0xa124, 0x0, 0x8, 0x13},
{0xa125, 0x0, 0x7, 0x10},
{0xa1c0, 0x0, 0x8, 0x0},
{0xa1c1, 0x0, 0x5, 0x4},
{0xa1c2, 0x0, 0x8, 0x0},
{0xa1c3, 0x0, 0x5, 0x10},
{0xa1c3, 0x5, 0x3, 0x0},
{0xa1c4, 0x0, 0x6, 0x0},
{0xa1c5, 0x0, 0x7, 0x10},
{0xa100, 0x0, 0x8, 0x0},
{0xa101, 0x0, 0x5, 0x10},
{0xa102, 0x0, 0x8, 0x0},
{0xa103, 0x0, 0x7, 0x40},
{0xa103, 0x7, 0x1, 0x0},
{0xa104, 0x0, 0x8, 0x18},
{0xa105, 0x0, 0x7, 0xa},
{0xa106, 0x0, 0x8, 0x20},
{0xa107, 0x0, 0x8, 0x40},
{0xa108, 0x0, 0x4, 0x0},
{0xa38c, 0x0, 0x8, 0xfc},
{0xa38d, 0x0, 0x8, 0x0},
{0xa38e, 0x0, 0x8, 0x7e},
{0xa38f, 0x0, 0x8, 0x0},
{0xa390, 0x0, 0x8, 0x2f},
{0xa60f, 0x5, 0x1, 0x1},
{0xa170, 0x0, 0x8, 0xdc},
{0xa171, 0x0, 0x2, 0x0},
{0xa2ae, 0x0, 0x1, 0x1},
{0xa2ae, 0x1, 0x1, 0x1},
{0xa392, 0x0, 0x1, 0x1},
{0xa391, 0x2, 0x1, 0x0},
{0xabc1, 0x0, 0x8, 0xff},
{0xabc2, 0x0, 0x8, 0x0},
{0xabc8, 0x0, 0x8, 0x8},
{0xabca, 0x0, 0x8, 0x10},
{0xabcb, 0x0, 0x1, 0x0},
{0xabc3, 0x5, 0x3, 0x7},
{0xabc0, 0x6, 0x1, 0x0},
{0xabc0, 0x4, 0x2, 0x0},
{0xa344, 0x4, 0x4, 0x1},
{0xabc0, 0x7, 0x1, 0x1},
{0xabc0, 0x2, 0x1, 0x1},
{0xa345, 0x0, 0x8, 0x66},
{0xa346, 0x0, 0x8, 0x66},
{0xa347, 0x0, 0x4, 0x0},
{0xa343, 0x0, 0x4, 0xa},
{0xa347, 0x4, 0x4, 0x2},
{0xa348, 0x0, 0x4, 0xc},
{0xa348, 0x4, 0x4, 0x7},
{0xa349, 0x0, 0x6, 0x2},
};
/* DVB USB compliant Linux driver for the Afatech 9005
* USB1.1 DVB-T receiver.
*
* Copyright (C) 2007 Luca Olivetti (luca@ventoso.org)
*
* Thanks to Afatech who kindly provided information.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* see Documentation/dvb/REDME.dvb-usb for more information
*/
#include "af9005.h"
/* debug */
int dvb_usb_af9005_debug;
module_param_named(debug, dvb_usb_af9005_debug, int, 0644);
MODULE_PARM_DESC(debug,
"set debugging level (1=info,xfer=2,rc=4,reg=8,i2c=16,fw=32 (or-able))."
DVB_USB_DEBUG_STATUS);
/* enable obnoxious led */
int dvb_usb_af9005_led = 1;
module_param_named(led, dvb_usb_af9005_led, bool, 0644);
MODULE_PARM_DESC(led, "enable led (default: 1).");
/* eeprom dump */
int dvb_usb_af9005_dump_eeprom = 0;
module_param_named(dump_eeprom, dvb_usb_af9005_dump_eeprom, int, 0);
MODULE_PARM_DESC(dump_eeprom, "dump contents of the eeprom.");
/* remote control decoder */
int (*rc_decode) (struct dvb_usb_device * d, u8 * data, int len, u32 * event,
int *state);
void *rc_keys;
int *rc_keys_size;
u8 regmask[8] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
struct af9005_device_state {
u8 sequence;
int led_state;
};
int af9005_usb_generic_rw(struct dvb_usb_device *d, u8 * wbuf, u16 wlen,
u8 * rbuf, u16 rlen, int delay_ms)
{
int actlen, ret = -ENOMEM;
if (wbuf == NULL || wlen == 0)
return -EINVAL;
if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
return ret;
deb_xfer(">>> ");
debug_dump(wbuf, wlen, deb_xfer);
ret = usb_bulk_msg(d->udev, usb_sndbulkpipe(d->udev,
2), wbuf, wlen,
&actlen, 2000);
if (ret)
err("bulk message failed: %d (%d/%d)", ret, wlen, actlen);
else
ret = actlen != wlen ? -1 : 0;
/* an answer is expected, and no error before */
if (!ret && rbuf && rlen) {
if (delay_ms)
msleep(delay_ms);
ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev,
0x01), rbuf,
rlen, &actlen, 2000);
if (ret)
err("recv bulk message failed: %d", ret);
else {
deb_xfer("<<< ");
debug_dump(rbuf, actlen, deb_xfer);
}
}
mutex_unlock(&d->usb_mutex);
return ret;
}
int af9005_usb_generic_write(struct dvb_usb_device *d, u8 * buf, u16 len)
{
return af9005_usb_generic_rw(d, buf, len, NULL, 0, 0);
}
int af9005_generic_read_write(struct dvb_usb_device *d, u16 reg,
int readwrite, int type, u8 * values, int len)
{
struct af9005_device_state *st = d->priv;
u8 obuf[16] = { 0 };
u8 ibuf[17] = { 0 };
u8 command;
int i;
int ret;
if (len < 1) {
err("generic read/write, less than 1 byte. Makes no sense.");
return -EINVAL;
}
if (len > 8) {
err("generic read/write, more than 8 bytes. Not supported.");
return -EINVAL;
}
obuf[0] = 14; /* rest of buffer length low */
obuf[1] = 0; /* rest of buffer length high */
obuf[2] = AF9005_REGISTER_RW; /* register operation */
obuf[3] = 12; /* rest of buffer length */
obuf[4] = st->sequence++; /* sequence number */
obuf[5] = (u8) (reg >> 8); /* register address */
obuf[6] = (u8) (reg & 0xff);
if (type == AF9005_OFDM_REG) {
command = AF9005_CMD_OFDM_REG;
} else {
command = AF9005_CMD_TUNER;
}
if (len > 1)
command |=
AF9005_CMD_BURST | AF9005_CMD_AUTOINC | (len - 1) << 3;
command |= readwrite;
if (readwrite == AF9005_CMD_WRITE)
for (i = 0; i < len; i++)
obuf[8 + i] = values[i];
else if (type == AF9005_TUNER_REG)
/* read command for tuner, the first byte contains the i2c address */
obuf[8] = values[0];
obuf[7] = command;
ret = af9005_usb_generic_rw(d, obuf, 16, ibuf, 17, 0);
if (ret)
return ret;
/* sanity check */
if (ibuf[2] != AF9005_REGISTER_RW_ACK) {
err("generic read/write, wrong reply code.");
return -EIO;
}
if (ibuf[3] != 0x0d) {
err("generic read/write, wrong length in reply.");
return -EIO;
}
if (ibuf[4] != obuf[4]) {
err("generic read/write, wrong sequence in reply.");
return -EIO;
}
/*
Windows driver doesn't check these fields, in fact sometimes
the register in the reply is different that what has been sent
if (ibuf[5] != obuf[5] || ibuf[6] != obuf[6]) {
err("generic read/write, wrong register in reply.");
return -EIO;
}
if (ibuf[7] != command) {
err("generic read/write wrong command in reply.");
return -EIO;
}
*/
if (ibuf[16] != 0x01) {
err("generic read/write wrong status code in reply.");
return -EIO;
}
if (readwrite == AF9005_CMD_READ)
for (i = 0; i < len; i++)
values[i] = ibuf[8 + i];
return 0;
}
int af9005_read_ofdm_register(struct dvb_usb_device *d, u16 reg, u8 * value)
{
int ret;
deb_reg("read register %x ", reg);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_READ, AF9005_OFDM_REG,
value, 1);
if (ret)
deb_reg("failed\n");
else
deb_reg("value %x\n", *value);
return ret;
}
int af9005_read_ofdm_registers(struct dvb_usb_device *d, u16 reg,
u8 * values, int len)
{
int ret;
deb_reg("read %d registers %x ", len, reg);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_READ, AF9005_OFDM_REG,
values, len);
if (ret)
deb_reg("failed\n");
else
debug_dump(values, len, deb_reg);
return ret;
}
int af9005_write_ofdm_register(struct dvb_usb_device *d, u16 reg, u8 value)
{
int ret;
u8 temp = value;
deb_reg("write register %x value %x ", reg, value);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_WRITE, AF9005_OFDM_REG,
&temp, 1);
if (ret)
deb_reg("failed\n");
else
deb_reg("ok\n");
return ret;
}
int af9005_write_ofdm_registers(struct dvb_usb_device *d, u16 reg,
u8 * values, int len)
{
int ret;
deb_reg("write %d registers %x values ", len, reg);
debug_dump(values, len, deb_reg);
ret = af9005_generic_read_write(d, reg,
AF9005_CMD_WRITE, AF9005_OFDM_REG,
values, len);
if (ret)
deb_reg("failed\n");
else
deb_reg("ok\n");
return ret;
}
int af9005_read_register_bits(struct dvb_usb_device *d, u16 reg, u8 pos,
u8 len, u8 * value)
{
u8 temp;
int ret;
deb_reg("read bits %x %x %x", reg, pos, len);
ret = af9005_read_ofdm_register(d, reg, &temp);
if (ret) {
deb_reg(" failed\n");
return ret;
}
*value = (temp >> pos) & regmask[len - 1];
deb_reg(" value %x\n", *value);
return 0;
}
int af9005_write_register_bits(struct dvb_usb_device *d, u16 reg, u8 pos,
u8 len, u8 value)
{
u8 temp, mask;
int ret;
deb_reg("write bits %x %x %x value %x\n", reg, pos, len, value);
if (pos == 0 && len == 8)
return af9005_write_ofdm_register(d, reg, value);
ret = af9005_read_ofdm_register(d, reg, &temp);
if (ret)
return ret;
mask = regmask[len - 1] << pos;
temp = (temp & ~mask) | ((value << pos) & mask);
return af9005_write_ofdm_register(d, reg, temp);
}
static int af9005_usb_read_tuner_registers(struct dvb_usb_device *d,
u16 reg, u8 * values, int len)
{
return af9005_generic_read_write(d, reg,
AF9005_CMD_READ, AF9005_TUNER_REG,
values, len);
}
static int af9005_usb_write_tuner_registers(struct dvb_usb_device *d,
u16 reg, u8 * values, int len)
{
return af9005_generic_read_write(d, reg,
AF9005_CMD_WRITE,
AF9005_TUNER_REG, values, len);
}
int af9005_write_tuner_registers(struct dvb_usb_device *d, u16 reg,
u8 * values, int len)
{
/* don't let the name of this function mislead you: it's just used
as an interface from the firmware to the i2c bus. The actual
i2c addresses are contained in the data */
int ret, i, done = 0, fail = 0;
u8 temp;
ret = af9005_usb_write_tuner_registers(d, reg, values, len);
if (ret)
return ret;
if (reg != 0xffff) {
/* check if write done (0xa40d bit 1) or fail (0xa40d bit 2) */
for (i = 0; i < 200; i++) {
ret =
af9005_read_ofdm_register(d,
xd_I2C_i2c_m_status_wdat_done,
&temp);
if (ret)
return ret;
done = temp & (regmask[i2c_m_status_wdat_done_len - 1]
<< i2c_m_status_wdat_done_pos);
if (done)
break;
fail = temp & (regmask[i2c_m_status_wdat_fail_len - 1]
<< i2c_m_status_wdat_fail_pos);
if (fail)
break;
msleep(50);
}
if (i == 200)
return -ETIMEDOUT;
if (fail) {
/* clear write fail bit */
af9005_write_register_bits(d,
xd_I2C_i2c_m_status_wdat_fail,
i2c_m_status_wdat_fail_pos,
i2c_m_status_wdat_fail_len,
1);
return -EIO;
}
/* clear write done bit */
ret =
af9005_write_register_bits(d,
xd_I2C_i2c_m_status_wdat_fail,
i2c_m_status_wdat_done_pos,
i2c_m_status_wdat_done_len, 1);
if (ret)
return ret;
}
return 0;
}
int af9005_read_tuner_registers(struct dvb_usb_device *d, u16 reg, u8 addr,
u8 * values, int len)
{
/* don't let the name of this function mislead you: it's just used
as an interface from the firmware to the i2c bus. The actual
i2c addresses are contained in the data */
int ret, i;
u8 temp, buf[2];
buf[0] = addr; /* tuner i2c address */
buf[1] = values[0]; /* tuner register */
values[0] = addr + 0x01; /* i2c read address */
if (reg == APO_REG_I2C_RW_SILICON_TUNER) {
/* write tuner i2c address to tuner, 0c00c0 undocumented, found by sniffing */
ret = af9005_write_tuner_registers(d, 0x00c0, buf, 2);
if (ret)
return ret;
}
/* send read command to ofsm */
ret = af9005_usb_read_tuner_registers(d, reg, values, 1);
if (ret)
return ret;
/* check if read done */
for (i = 0; i < 200; i++) {
ret = af9005_read_ofdm_register(d, 0xa408, &temp);
if (ret)
return ret;
if (temp & 0x01)
break;
msleep(50);
}
if (i == 200)
return -ETIMEDOUT;
/* clear read done bit (by writing 1) */
ret = af9005_write_ofdm_register(d, xd_I2C_i2c_m_data8, 1);
if (ret)
return ret;
/* get read data (available from 0xa400) */
for (i = 0; i < len; i++) {
ret = af9005_read_ofdm_register(d, 0xa400 + i, &temp);
if (ret)
return ret;
values[i] = temp;
}
return 0;
}
static int af9005_i2c_write(struct dvb_usb_device *d, u8 i2caddr, u8 reg,
u8 * data, int len)
{
int ret, i;
u8 buf[3];
deb_i2c("i2c_write i2caddr %x, reg %x, len %d data ", i2caddr,
reg, len);
debug_dump(data, len, deb_i2c);
for (i = 0; i < len; i++) {
buf[0] = i2caddr;
buf[1] = reg + (u8) i;
buf[2] = data[i];
ret =
af9005_write_tuner_registers(d,
APO_REG_I2C_RW_SILICON_TUNER,
buf, 3);
if (ret) {
deb_i2c("i2c_write failed\n");
return ret;
}
}
deb_i2c("i2c_write ok\n");
return 0;
}
static int af9005_i2c_read(struct dvb_usb_device *d, u8 i2caddr, u8 reg,
u8 * data, int len)
{
int ret, i;
u8 temp;
deb_i2c("i2c_read i2caddr %x, reg %x, len %d\n ", i2caddr, reg, len);
for (i = 0; i < len; i++) {
temp = reg + i;
ret =
af9005_read_tuner_registers(d,
APO_REG_I2C_RW_SILICON_TUNER,
i2caddr, &temp, 1);
if (ret) {
deb_i2c("i2c_read failed\n");
return ret;
}
data[i] = temp;
}
deb_i2c("i2c data read: ");
debug_dump(data, len, deb_i2c);
return 0;
}
static int af9005_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
int num)
{
/* only implements what the mt2060 module does, don't know how
to make it really generic */
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int ret;
u8 reg, addr;
u8 *value;
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
if (num > 2)
warn("more than 2 i2c messages at a time is not handled yet. TODO.");
if (num == 2) {
/* reads a single register */
reg = *msg[0].buf;
addr = msg[0].addr;
value = msg[1].buf;
ret = af9005_i2c_read(d, addr, reg, value, 1);
if (ret == 0)
ret = 2;
} else {
/* write one or more registers */
reg = msg[0].buf[0];
addr = msg[0].addr;
value = &msg[0].buf[1];
ret = af9005_i2c_write(d, addr, reg, value, msg[0].len - 1);
if (ret == 0)
ret = 1;
}
mutex_unlock(&d->i2c_mutex);
return ret;
}
static u32 af9005_i2c_func(struct i2c_adapter *adapter)
{
return I2C_FUNC_I2C;
}
static struct i2c_algorithm af9005_i2c_algo = {
.master_xfer = af9005_i2c_xfer,
.functionality = af9005_i2c_func,
};
int af9005_send_command(struct dvb_usb_device *d, u8 command, u8 * wbuf,
int wlen, u8 * rbuf, int rlen)
{
struct af9005_device_state *st = d->priv;
int ret, i, packet_len;
u8 buf[64];
u8 ibuf[64];
if (wlen < 0) {
err("send command, wlen less than 0 bytes. Makes no sense.");
return -EINVAL;
}
if (wlen > 54) {
err("send command, wlen more than 54 bytes. Not supported.");
return -EINVAL;
}
if (rlen > 54) {
err("send command, rlen more than 54 bytes. Not supported.");
return -EINVAL;
}
packet_len = wlen + 5;
buf[0] = (u8) (packet_len & 0xff);
buf[1] = (u8) ((packet_len & 0xff00) >> 8);
buf[2] = 0x26; /* packet type */
buf[3] = wlen + 3;
buf[4] = st->sequence++;
buf[5] = command;
buf[6] = wlen;
for (i = 0; i < wlen; i++)
buf[7 + i] = wbuf[i];
ret = af9005_usb_generic_rw(d, buf, wlen + 7, ibuf, rlen + 7, 0);
if (ret)
return ret;
if (ibuf[2] != 0x27) {
err("send command, wrong reply code.");
return -EIO;
}
if (ibuf[4] != buf[4]) {
err("send command, wrong sequence in reply.");
return -EIO;
}
if (ibuf[5] != 0x01) {
err("send command, wrong status code in reply.");
return -EIO;
}
if (ibuf[6] != rlen) {
err("send command, invalid data length in reply.");
return -EIO;
}
for (i = 0; i < rlen; i++)
rbuf[i] = ibuf[i + 7];
return 0;
}
int af9005_read_eeprom(struct dvb_usb_device *d, u8 address, u8 * values,
int len)
{
struct af9005_device_state *st = d->priv;
u8 obuf[16], ibuf[14];
int ret, i;
memset(obuf, 0, sizeof(obuf));
memset(ibuf, 0, sizeof(ibuf));
obuf[0] = 14; /* length of rest of packet low */
obuf[1] = 0; /* length of rest of packer high */
obuf[2] = 0x2a; /* read/write eeprom */
obuf[3] = 12; /* size */
obuf[4] = st->sequence++;
obuf[5] = 0; /* read */
obuf[6] = len;
obuf[7] = address;
ret = af9005_usb_generic_rw(d, obuf, 16, ibuf, 14, 0);
if (ret)
return ret;
if (ibuf[2] != 0x2b) {
err("Read eeprom, invalid reply code");
return -EIO;
}
if (ibuf[3] != 10) {
err("Read eeprom, invalid reply length");
return -EIO;
}
if (ibuf[4] != obuf[4]) {
err("Read eeprom, wrong sequence in reply ");
return -EIO;
}
if (ibuf[5] != 1) {
err("Read eeprom, wrong status in reply ");
return -EIO;
}
for (i = 0; i < len; i++) {
values[i] = ibuf[6 + i];
}
return 0;
}
static int af9005_boot_packet(struct usb_device *udev, int type, u8 * reply)
{
u8 buf[FW_BULKOUT_SIZE + 2];
u16 checksum;
int act_len, i, ret;
memset(buf, 0, sizeof(buf));
buf[0] = (u8) (FW_BULKOUT_SIZE & 0xff);
buf[1] = (u8) ((FW_BULKOUT_SIZE >> 8) & 0xff);
switch (type) {
case FW_CONFIG:
buf[2] = 0x11;
buf[3] = 0x04;
buf[4] = 0x00; /* sequence number, original driver doesn't increment it here */
buf[5] = 0x03;
checksum = buf[4] + buf[5];
buf[6] = (u8) ((checksum >> 8) & 0xff);
buf[7] = (u8) (checksum & 0xff);
break;
case FW_CONFIRM:
buf[2] = 0x11;
buf[3] = 0x04;
buf[4] = 0x00; /* sequence number, original driver doesn't increment it here */
buf[5] = 0x01;
checksum = buf[4] + buf[5];
buf[6] = (u8) ((checksum >> 8) & 0xff);
buf[7] = (u8) (checksum & 0xff);
break;
case FW_BOOT:
buf[2] = 0x10;
buf[3] = 0x08;
buf[4] = 0x00; /* sequence number, original driver doesn't increment it here */
buf[5] = 0x97;
buf[6] = 0xaa;
buf[7] = 0x55;
buf[8] = 0xa5;
buf[9] = 0x5a;
checksum = 0;
for (i = 4; i <= 9; i++)
checksum += buf[i];
buf[10] = (u8) ((checksum >> 8) & 0xff);
buf[11] = (u8) (checksum & 0xff);
break;
default:
err("boot packet invalid boot packet type");
return -EINVAL;
}
deb_fw(">>> ");
debug_dump(buf, FW_BULKOUT_SIZE + 2, deb_fw);
ret = usb_bulk_msg(udev,
usb_sndbulkpipe(udev, 0x02),
buf, FW_BULKOUT_SIZE + 2, &act_len, 2000);
if (ret)
err("boot packet bulk message failed: %d (%d/%d)", ret,
FW_BULKOUT_SIZE + 2, act_len);
else
ret = act_len != FW_BULKOUT_SIZE + 2 ? -1 : 0;
if (ret)
return ret;
memset(buf, 0, 9);
ret = usb_bulk_msg(udev,
usb_rcvbulkpipe(udev, 0x01), buf, 9, &act_len, 2000);
if (ret) {
err("boot packet recv bulk message failed: %d", ret);
return ret;
}
deb_fw("<<< ");
debug_dump(buf, act_len, deb_fw);
checksum = 0;
switch (type) {
case FW_CONFIG:
if (buf[2] != 0x11) {
err("boot bad config header.");
return -EIO;
}
if (buf[3] != 0x05) {
err("boot bad config size.");
return -EIO;
}
if (buf[4] != 0x00) {
err("boot bad config sequence.");
return -EIO;
}
if (buf[5] != 0x04) {
err("boot bad config subtype.");
return -EIO;
}
for (i = 4; i <= 6; i++)
checksum += buf[i];
if (buf[7] * 256 + buf[8] != checksum) {
err("boot bad config checksum.");
return -EIO;
}
*reply = buf[6];
break;
case FW_CONFIRM:
if (buf[2] != 0x11) {
err("boot bad confirm header.");
return -EIO;
}
if (buf[3] != 0x05) {
err("boot bad confirm size.");
return -EIO;
}
if (buf[4] != 0x00) {
err("boot bad confirm sequence.");
return -EIO;
}
if (buf[5] != 0x02) {
err("boot bad confirm subtype.");
return -EIO;
}
for (i = 4; i <= 6; i++)
checksum += buf[i];
if (buf[7] * 256 + buf[8] != checksum) {
err("boot bad confirm checksum.");
return -EIO;
}
*reply = buf[6];
break;
case FW_BOOT:
if (buf[2] != 0x10) {
err("boot bad boot header.");
return -EIO;
}
if (buf[3] != 0x05) {
err("boot bad boot size.");
return -EIO;
}
if (buf[4] != 0x00) {
err("boot bad boot sequence.");
return -EIO;
}
if (buf[5] != 0x01) {
err("boot bad boot pattern 01.");
return -EIO;
}
if (buf[6] != 0x10) {
err("boot bad boot pattern 10.");
return -EIO;
}
for (i = 4; i <= 6; i++)
checksum += buf[i];
if (buf[7] * 256 + buf[8] != checksum) {
err("boot bad boot checksum.");
return -EIO;
}
break;
}
return 0;
}
int af9005_download_firmware(struct usb_device *udev, const struct firmware *fw)
{
int i, packets, ret, act_len;
u8 buf[FW_BULKOUT_SIZE + 2];
u8 reply;
ret = af9005_boot_packet(udev, FW_CONFIG, &reply);
if (ret)
return ret;
if (reply != 0x01) {
err("before downloading firmware, FW_CONFIG expected 0x01, received 0x%x", reply);
return -EIO;
}
packets = fw->size / FW_BULKOUT_SIZE;
buf[0] = (u8) (FW_BULKOUT_SIZE & 0xff);
buf[1] = (u8) ((FW_BULKOUT_SIZE >> 8) & 0xff);
for (i = 0; i < packets; i++) {
memcpy(&buf[2], fw->data + i * FW_BULKOUT_SIZE,
FW_BULKOUT_SIZE);
deb_fw(">>> ");
debug_dump(buf, FW_BULKOUT_SIZE + 2, deb_fw);
ret = usb_bulk_msg(udev,
usb_sndbulkpipe(udev, 0x02),
buf, FW_BULKOUT_SIZE + 2, &act_len, 1000);
if (ret) {
err("firmware download failed at packet %d with code %d", i, ret);
return ret;
}
}
ret = af9005_boot_packet(udev, FW_CONFIRM, &reply);
if (ret)
return ret;
if (reply != (u8) (packets & 0xff)) {
err("after downloading firmware, FW_CONFIRM expected 0x%x, received 0x%x", packets & 0xff, reply);
return -EIO;
}
ret = af9005_boot_packet(udev, FW_BOOT, &reply);
if (ret)
return ret;
ret = af9005_boot_packet(udev, FW_CONFIG, &reply);
if (ret)
return ret;
if (reply != 0x02) {
err("after downloading firmware, FW_CONFIG expected 0x02, received 0x%x", reply);
return -EIO;
}
return 0;
}
int af9005_led_control(struct dvb_usb_device *d, int onoff)
{
struct af9005_device_state *st = d->priv;
int temp, ret;
if (onoff && dvb_usb_af9005_led)
temp = 1;
else
temp = 0;
if (st->led_state != temp) {
ret =
af9005_write_register_bits(d, xd_p_reg_top_locken1,
reg_top_locken1_pos,
reg_top_locken1_len, temp);
if (ret)
return ret;
ret =
af9005_write_register_bits(d, xd_p_reg_top_lock1,
reg_top_lock1_pos,
reg_top_lock1_len, temp);
if (ret)
return ret;
st->led_state = temp;
}
return 0;
}
static int af9005_frontend_attach(struct dvb_usb_adapter *adap)
{
u8 buf[8];
int i;
/* without these calls the first commands after downloading
the firmware fail. I put these calls here to simulate
what it is done in dvb-usb-init.c.
*/
struct usb_device *udev = adap->dev->udev;
usb_clear_halt(udev, usb_sndbulkpipe(udev, 2));
usb_clear_halt(udev, usb_rcvbulkpipe(udev, 1));
if (dvb_usb_af9005_dump_eeprom) {
printk("EEPROM DUMP\n");
for (i = 0; i < 255; i += 8) {
af9005_read_eeprom(adap->dev, i, buf, 8);
printk("ADDR %x ", i);
debug_dump(buf, 8, printk);
}
}
adap->fe = af9005_fe_attach(adap->dev);
return 0;
}
static int af9005_rc_query(struct dvb_usb_device *d, u32 * event, int *state)
{
struct af9005_device_state *st = d->priv;
int ret, len;
u8 obuf[5];
u8 ibuf[256];
*state = REMOTE_NO_KEY_PRESSED;
if (rc_decode == NULL) {
/* it shouldn't never come here */
return 0;
}
/* deb_info("rc_query\n"); */
obuf[0] = 3; /* rest of packet length low */
obuf[1] = 0; /* rest of packet lentgh high */
obuf[2] = 0x40; /* read remote */
obuf[3] = 1; /* rest of packet length */
obuf[4] = st->sequence++; /* sequence number */
ret = af9005_usb_generic_rw(d, obuf, 5, ibuf, 256, 0);
if (ret) {
err("rc query failed");
return ret;
}
if (ibuf[2] != 0x41) {
err("rc query bad header.");
return -EIO;
}
if (ibuf[4] != obuf[4]) {
err("rc query bad sequence.");
return -EIO;
}
len = ibuf[5];
if (len > 246) {
err("rc query invalid length");
return -EIO;
}
if (len > 0) {
deb_rc("rc data (%d) ", len);
debug_dump((ibuf + 6), len, deb_rc);
ret = rc_decode(d, &ibuf[6], len, event, state);
if (ret) {
err("rc_decode failed");
return ret;
} else {
deb_rc("rc_decode state %x event %x\n", *state, *event);
if (*state == REMOTE_KEY_REPEAT)
*event = d->last_event;
}
}
return 0;
}
static int af9005_power_ctrl(struct dvb_usb_device *d, int onoff)
{
return 0;
}
static int af9005_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
{
int ret;
deb_info("pid filter control onoff %d\n", onoff);
if (onoff) {
ret =
af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 1);
if (ret)
return ret;
ret =
af9005_write_register_bits(adap->dev,
XD_MP2IF_DMX_CTRL, 1, 1, 1);
if (ret)
return ret;
ret =
af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 1);
} else
ret =
af9005_write_ofdm_register(adap->dev, XD_MP2IF_DMX_CTRL, 0);
if (ret)
return ret;
deb_info("pid filter control ok\n");
return 0;
}
static int af9005_pid_filter(struct dvb_usb_adapter *adap, int index,
u16 pid, int onoff)
{
u8 cmd = index & 0x1f;
int ret;
deb_info("set pid filter, index %d, pid %x, onoff %d\n", index,
pid, onoff);
if (onoff) {
/* cannot use it as pid_filter_ctrl since it has to be done
before setting the first pid */
if (adap->feedcount == 1) {
deb_info("first pid set, enable pid table\n");
ret = af9005_pid_filter_control(adap, onoff);
if (ret)
return ret;
}
ret =
af9005_write_ofdm_register(adap->dev,
XD_MP2IF_PID_DATA_L,
(u8) (pid & 0xff));
if (ret)
return ret;
ret =
af9005_write_ofdm_register(adap->dev,
XD_MP2IF_PID_DATA_H,
(u8) (pid >> 8));
if (ret)
return ret;
cmd |= 0x20 | 0x40;
} else {
if (adap->feedcount == 0) {
deb_info("last pid unset, disable pid table\n");
ret = af9005_pid_filter_control(adap, onoff);
if (ret)
return ret;
}
}
ret = af9005_write_ofdm_register(adap->dev, XD_MP2IF_PID_IDX, cmd);
if (ret)
return ret;
deb_info("set pid ok\n");
return 0;
}
static int af9005_identify_state(struct usb_device *udev,
struct dvb_usb_device_properties *props,
struct dvb_usb_device_description **desc,
int *cold)
{
int ret;
u8 reply;
ret = af9005_boot_packet(udev, FW_CONFIG, &reply);
if (ret)
return ret;
deb_info("result of FW_CONFIG in identify state %d\n", reply);
if (reply == 0x01)
*cold = 1;
else if (reply == 0x02)
*cold = 0;
else
return -EIO;
deb_info("Identify state cold = %d\n", *cold);
return 0;
}
static struct dvb_usb_device_properties af9005_properties;
static int af9005_usb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
return dvb_usb_device_init(intf, &af9005_properties, THIS_MODULE, NULL);
}
static struct usb_device_id af9005_usb_table[] = {
{USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9005)},
{USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_USB_XE)},
{0},
};
MODULE_DEVICE_TABLE(usb, af9005_usb_table);
static struct dvb_usb_device_properties af9005_properties = {
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
.usb_ctrl = DEVICE_SPECIFIC,
.firmware = "af9005.fw",
.download_firmware = af9005_download_firmware,
.no_reconnect = 1,
.size_of_priv = sizeof(struct af9005_device_state),
.num_adapters = 1,
.adapter = {
{
.caps =
DVB_USB_ADAP_HAS_PID_FILTER |
DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
.pid_filter_count = 32,
.pid_filter = af9005_pid_filter,
/* .pid_filter_ctrl = af9005_pid_filter_control, */
.frontend_attach = af9005_frontend_attach,
/* .tuner_attach = af9005_tuner_attach, */
/* parameter for the MPEG2-data transfer */
.stream = {
.type = USB_BULK,
.count = 10,
.endpoint = 0x04,
.u = {
.bulk = {
.buffersize = 4096, /* actual size seen is 3948 */
}
}
},
}
},
.power_ctrl = af9005_power_ctrl,
.identify_state = af9005_identify_state,
.i2c_algo = &af9005_i2c_algo,
.rc_interval = 200,
.rc_key_map = NULL,
.rc_key_map_size = 0,
.rc_query = af9005_rc_query,
.num_device_descs = 2,
.devices = {
{.name = "Afatech DVB-T USB1.1 stick",
.cold_ids = {&af9005_usb_table[0], NULL},
.warm_ids = {NULL},
},
{.name = "TerraTec Cinergy T USB XE",
.cold_ids = {&af9005_usb_table[1], NULL},
.warm_ids = {NULL},
},
{NULL},
}
};
/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver af9005_usb_driver = {
.name = "dvb_usb_af9005",
.probe = af9005_usb_probe,
.disconnect = dvb_usb_device_exit,
.id_table = af9005_usb_table,
};
/* module stuff */
static int __init af9005_usb_module_init(void)
{
int result;
if ((result = usb_register(&af9005_usb_driver))) {
err("usb_register failed. (%d)", result);
return result;
}
rc_decode = symbol_request(af9005_rc_decode);
rc_keys = symbol_request(af9005_rc_keys);
rc_keys_size = symbol_request(af9005_rc_keys_size);
if (rc_decode == NULL || rc_keys == NULL || rc_keys_size == NULL) {
err("af9005_rc_decode function not found, disabling remote");
af9005_properties.rc_query = NULL;
} else {
af9005_properties.rc_key_map = rc_keys;
af9005_properties.rc_key_map_size = *rc_keys_size;
}
return 0;
}
static void __exit af9005_usb_module_exit(void)
{
/* release rc decode symbols */
if (rc_decode != NULL)
symbol_put(af9005_rc_decode);
if (rc_keys != NULL)
symbol_put(af9005_rc_keys);
if (rc_keys_size != NULL)
symbol_put(af9005_rc_keys_size);
/* deregister this driver from the USB subsystem */
usb_deregister(&af9005_usb_driver);
}
module_init(af9005_usb_module_init);
module_exit(af9005_usb_module_exit);
MODULE_AUTHOR("Luca Olivetti <luca@ventoso.org>");
MODULE_DESCRIPTION("Driver for Afatech 9005 DVB-T USB1.1 stick");
MODULE_VERSION("1.0");
MODULE_LICENSE("GPL");
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,6 +11,7 @@
/* Vendor IDs */
#define USB_VID_ADSTECH 0x06e1
#define USB_VID_AFATECH 0x15a4
#define USB_VID_ALCOR_MICRO 0x058f
#define USB_VID_ANCHOR 0x0547
#define USB_VID_ANUBIS_ELECTRONIC 0x10fd
......@@ -35,6 +36,7 @@
#define USB_VID_MSI 0x0db0
#define USB_VID_OPERA1 0x695c
#define USB_VID_PINNACLE 0x2304
#define USB_VID_TERRATEC 0x0ccd
#define USB_VID_VISIONPLUS 0x13d3
#define USB_VID_TWINHAN 0x1822
#define USB_VID_ULTIMA_ELECTRONIC 0x05d8
......@@ -44,6 +46,7 @@
/* Product IDs */
#define USB_PID_ADSTECH_USB2_COLD 0xa333
#define USB_PID_ADSTECH_USB2_WARM 0xa334
#define USB_PID_AFATECH_AF9005 0x9020
#define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001
#define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002
#define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800
......@@ -69,6 +72,7 @@
#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
#define USB_PID_TERRATEC_CINERGY_T_USB_XE 0x0055
#define USB_PID_TWINHAN_VP7041_COLD 0x3201
#define USB_PID_TWINHAN_VP7041_WARM 0x3202
#define USB_PID_TWINHAN_VP7020_COLD 0x3203
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment