struct firmware_description {
unsigned int type;
v4l2_std_id id;
+ __u16 int_freq;
unsigned char *ptr;
unsigned int size;
};
unsigned int type;
v4l2_std_id id;
v4l2_std_id std_req;
+ __u16 int_freq;
unsigned int scode_table;
int scode_nr;
};
return 0;
}
-void dump_firm_type(unsigned int type)
+#define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0)
+void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq)
{
if (type & BASE)
printk("BASE ");
printk("INPUT2 ");
if (type & SCODE)
printk("SCODE ");
+ if (type & HAS_IF)
+ printk("HAS_IF_%d ", int_freq);
}
static v4l2_std_id parse_audio_std_option(void)
while (p < endp) {
__u32 type, size;
v4l2_std_id id;
+ __u16 int_freq = 0;
n++;
if (n >= n_array) {
id = le64_to_cpu(*(v4l2_std_id *) p);
p += sizeof(id);
+ if (type & HAS_IF) {
+ int_freq = le16_to_cpu(*(__u16 *) p);
+ p += sizeof(int_freq);
+ }
+
size = le32_to_cpu(*(__u32 *) p);
p += sizeof(size);
}
tuner_dbg("Reading firmware type ");
if (debug) {
- dump_firm_type(type);
+ dump_firm_type_and_int_freq(type, int_freq);
printk("(%x), id %llx, size=%d.\n",
- type, (unsigned long long)id, size);
+ type, (unsigned long long)id, size);
}
memcpy(priv->firm[n].ptr, p, size);
priv->firm[n].type = type;
priv->firm[n].id = id;
priv->firm[n].size = size;
+ priv->firm[n].int_freq = int_freq;
p += size;
}
{
struct xc2028_data *priv = fe->tuner_priv;
int i, best_i = -1, best_nr_matches = 0;
+ unsigned int ign_firm_type_mask = 0;
tuner_dbg("%s called, want type=", __FUNCTION__);
if (debug) {
if (type & BASE)
type &= BASE_TYPES;
- else if (type & SCODE)
+ else if (type & SCODE) {
type &= SCODE_TYPES;
- else if (type & DTV_TYPES)
+ ign_firm_type_mask = HAS_IF;
+ } else if (type & DTV_TYPES)
type &= DTV_TYPES;
else if (type & STD_SPECIFIC_TYPES)
type &= STD_SPECIFIC_TYPES;
/* Seek for exact match */
for (i = 0; i < priv->firm_size; i++) {
- if ((type == priv->firm[i].type) && (*id == priv->firm[i].id))
+ if ((type == (priv->firm[i].type & ~ign_firm_type_mask)) &&
+ (*id == priv->firm[i].id))
goto found;
}
v4l2_std_id match_mask;
int nr_matches;
- if (type != priv->firm[i].type)
+ if (type != (priv->firm[i].type & ~ign_firm_type_mask))
continue;
match_mask = *id & priv->firm[i].id;
}
static int load_scode(struct dvb_frontend *fe, unsigned int type,
- v4l2_std_id *id, int scode)
+ v4l2_std_id *id, __u16 int_freq, int scode)
{
struct xc2028_data *priv = fe->tuner_priv;
int pos, rc;
tuner_dbg("%s called\n", __FUNCTION__);
- pos = seek_firmware(fe, type, id);
- if (pos < 0)
- return pos;
+ if (!int_freq) {
+ pos = seek_firmware(fe, type, id);
+ if (pos < 0)
+ return pos;
+ } else {
+ for (pos = 0; pos < priv->firm_size; pos++) {
+ if ((priv->firm[pos].int_freq == int_freq) &&
+ (priv->firm[pos].type & HAS_IF))
+ break;
+ }
+ if (pos == priv->firm_size)
+ return -ENOENT;
+ }
p = priv->firm[pos].ptr;
- /* 16 SCODE entries per file; each SCODE entry is 12 bytes and
- * has a 2-byte size header in the firmware format. */
- if (priv->firm[pos].size != 14 * 16 || scode >= 16 ||
- le16_to_cpu(*(__u16 *)(p + 14 * scode)) != 12)
- return -EINVAL;
+ if (priv->firm[pos].type & HAS_IF) {
+ if (priv->firm[pos].size != 12 * 16 || scode >= 16)
+ return -EINVAL;
+ p += 12 * scode;
+ } else {
+ /* 16 SCODE entries per file; each SCODE entry is 12 bytes and
+ * has a 2-byte size header in the firmware format. */
+ if (priv->firm[pos].size != 14 * 16 || scode >= 16 ||
+ le16_to_cpu(*(__u16 *)(p + 14 * scode)) != 12)
+ return -EINVAL;
+ p += 14 * scode + 2;
+ }
tuner_info("Loading SCODE for type=");
- dump_firm_type(priv->firm[pos].type);
+ dump_firm_type_and_int_freq(priv->firm[pos].type,
+ priv->firm[pos].int_freq);
printk("(%x), id %016llx.\n", priv->firm[pos].type,
(unsigned long long)*id);
if (rc < 0)
return -EIO;
- rc = i2c_send(priv, p + 14 * scode + 2, 12);
+ rc = i2c_send(priv, p, 12);
if (rc < 0)
return -EIO;
}
static int check_firmware(struct dvb_frontend *fe, unsigned int type,
- v4l2_std_id std)
+ v4l2_std_id std, __u16 int_freq)
{
struct xc2028_data *priv = fe->tuner_priv;
struct firmware_properties new_fw;
return rc;
}
- if (priv->ctrl.mts)
+ if (priv->ctrl.mts && !(type & FM))
type |= MTS;
retry:
new_fw.std_req = std;
new_fw.scode_table = SCODE | priv->ctrl.scode_table;
new_fw.scode_nr = 0;
+ new_fw.int_freq = int_freq;
tuner_dbg("checking firmware, user requested type=");
if (debug) {
dump_firm_type(new_fw.type);
- printk("(%x), id %016llx, scode_tbl ", new_fw.type,
+ printk("(%x), id %016llx, ", new_fw.type,
(unsigned long long)new_fw.std_req);
- dump_firm_type(priv->ctrl.scode_table);
- printk("(%x), scode_nr %d\n", priv->ctrl.scode_table,
- new_fw.scode_nr);
+ if (!int_freq) {
+ printk("scode_tbl ");
+ dump_firm_type(priv->ctrl.scode_table);
+ printk("(%x), ", priv->ctrl.scode_table);
+ } else
+ printk("int_freq %d, ", new_fw.int_freq);
+ printk("scode_nr %d\n", new_fw.scode_nr);
}
/* No need to reload base firmware if it matches */
goto check_device;
}
+ if (new_fw.type & FM)
+ goto check_device;
+
/* Load SCODE firmware, if exists */
tuner_dbg("Trying to load scode %d\n", new_fw.scode_nr);
- rc = load_scode(fe, new_fw.type | new_fw.scode_table,
- &new_fw.id, new_fw.scode_nr);
+ rc = load_scode(fe, new_fw.type | new_fw.scode_table, &new_fw.id,
+ new_fw.int_freq, new_fw.scode_nr);
check_device:
if (xc2028_get_reg(priv, 0x0004, &version) < 0 ||
#define DIV 15625
static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
- enum tuner_mode new_mode,
- unsigned int type,
- v4l2_std_id std)
+ enum tuner_mode new_mode,
+ unsigned int type,
+ v4l2_std_id std,
+ u16 int_freq)
{
struct xc2028_data *priv = fe->tuner_priv;
int rc = -EINVAL;
tuner_dbg("should set frequency %d kHz\n", freq / 1000);
- if (check_firmware(fe, type, std) < 0)
+ if (check_firmware(fe, type, std, int_freq) < 0)
goto ret;
/* On some cases xc2028 can disable video output, if
*/
if (new_mode == T_ANALOG_TV) {
rc = send_seq(priv, {0x00, 0x00});
+ } else if (priv->cur_fw.type & ATSC) {
+ offset = 1750000;
} else {
offset = 2750000;
- if (priv->cur_fw.type & DTV7)
+ /*
+ * We must adjust the offset by 500kHz in two cases in order
+ * to correctly center the IF output:
+ * 1) When the ZARLINK456 or DIBCOM52 tables were explicitly
+ * selected and a 7MHz channel is tuned;
+ * 2) When tuning a VHF channel with DTV78 firmware.
+ */
+ if (((priv->cur_fw.type & DTV7) &&
+ (priv->cur_fw.scode_table & (ZARLINK456 | DIBCOM52))) ||
+ ((priv->cur_fw.type & DTV78) && freq < 470000000))
offset -= 500000;
}
if (priv->ctrl.input1)
type |= INPUT1;
return generic_set_freq(fe, (625l * p->frequency) / 10,
- T_ANALOG_TV, type, 0);
+ T_ANALOG_TV, type, 0, 0);
}
/* if std is not defined, choose one */
p->std |= parse_audio_std_option();
return generic_set_freq(fe, 62500l * p->frequency,
- T_ANALOG_TV, type, p->std);
+ T_ANALOG_TV, type, p->std, 0);
}
static int xc2028_set_params(struct dvb_frontend *fe,
struct xc2028_data *priv = fe->tuner_priv;
unsigned int type=0;
fe_bandwidth_t bw = BANDWIDTH_8_MHZ;
+ u16 demod = 0;
tuner_dbg("%s called\n", __FUNCTION__);
type |= D2620;
switch(fe->ops.info.type) {
- case FE_QPSK:
- break;
case FE_OFDM:
bw = p->u.ofdm.bandwidth;
break;
case FE_QAM:
+ tuner_info("WARN: There are some reports that "
+ "QAM 6 MHz doesn't work.\n"
+ "If this works for you, please report by "
+ "e-mail to: v4l-dvb-maintainer@linuxtv.org\n");
bw = BANDWIDTH_6_MHZ;
type |= QAM;
break;
case FE_ATSC:
bw = BANDWIDTH_6_MHZ;
+ /* The only ATSC firmware (at least on v2.7) is D2633,
+ so overrides ctrl->d2633 */
type |= ATSC| D2633;
+ type &= ~D2620;
break;
+ /* DVB-S is not supported */
+ default:
+ return -EINVAL;
}
- bw = p->u.ofdm.bandwidth;
-
- /* FIXME:
- There are two Scodes that will never be selected:
- DTV78 ZARLINK456, DTV78 DIBCOM52
- When it should opt for DTV78 instead of DTV7 or DTV8?
- */
switch (bw) {
case BANDWIDTH_8_MHZ:
- type |= DTV8 | F8MHZ;
+ if (p->frequency < 470000000)
+ priv->ctrl.vhfbw7 = 0;
+ else
+ priv->ctrl.uhfbw8 = 1;
+ type |= (priv->ctrl.vhfbw7 && priv->ctrl.uhfbw8) ? DTV78 : DTV8;
+ type |= F8MHZ;
break;
case BANDWIDTH_7_MHZ:
- type |= DTV7 | F8MHZ;
+ if (p->frequency < 470000000)
+ priv->ctrl.vhfbw7 = 1;
+ else
+ priv->ctrl.uhfbw8 = 0;
+ type |= (priv->ctrl.vhfbw7 && priv->ctrl.uhfbw8) ? DTV78 : DTV7;
+ type |= F8MHZ;
break;
case BANDWIDTH_6_MHZ:
- type |= DTV6 ;
+ type |= DTV6;
+ priv->ctrl.vhfbw7 = 0;
+ priv->ctrl.uhfbw8 = 0;
break;
default:
tuner_err("error: bandwidth not supported.\n");
};
+ /* All S-code tables need a 200kHz shift */
+ if (priv->ctrl.demod)
+ demod = priv->ctrl.demod + 200;
+
return generic_set_freq(fe, p->frequency,
- T_DIGITAL_TV, type, 0);
+ T_DIGITAL_TV, type, 0, demod);
}
static int xc2028_sleep(struct dvb_frontend *fe)
};
-void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg)
+struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe,
+ struct xc2028_config *cfg)
{
struct xc2028_data *priv;
void *video_dev;