Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9e54512 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

[media] af9005-fe: convert set_fontend to use DVBv5 parameters



Instead of using dvb_frontend_parameters struct, that were
designed for a subset of the supported standards, use the DVBv5
cache information.

Also, fill the supported delivery systems at dvb_frontend_ops
struct.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 5942c679
Loading
Loading
Loading
Loading
+52 −50
Original line number Original line Diff line number Diff line
@@ -303,7 +303,7 @@ static int af9005_get_pre_vit_err_bit_count(struct dvb_frontend *fe,
		return -EINVAL;
		return -EINVAL;
	}
	}


	/* read constellation mode */
	/* read modulation mode */
	ret =
	ret =
	    af9005_read_register_bits(state->d, xd_g_reg_tpsd_const,
	    af9005_read_register_bits(state->d, xd_g_reg_tpsd_const,
				      reg_tpsd_const_pos, reg_tpsd_const_len,
				      reg_tpsd_const_pos, reg_tpsd_const_len,
@@ -321,7 +321,7 @@ static int af9005_get_pre_vit_err_bit_count(struct dvb_frontend *fe,
		bits = 6;
		bits = 6;
		break;
		break;
	default:
	default:
		err("invalid constellation mode");
		err("invalid modulation mode");
		return -EINVAL;
		return -EINVAL;
	}
	}
	*pre_bit_count = super_frame_count * 68 * 4 * x * bits;
	*pre_bit_count = super_frame_count * 68 * 4 * x * bits;
@@ -533,13 +533,13 @@ static int af9005_fe_read_signal_strength(struct dvb_frontend *fe,


static int af9005_fe_read_snr(struct dvb_frontend *fe, u16 * snr)
static int af9005_fe_read_snr(struct dvb_frontend *fe, u16 * snr)
{
{
	/* the snr can be derived from the ber and the constellation
	/* the snr can be derived from the ber and the modulation
	   but I don't think this kind of complex calculations belong
	   but I don't think this kind of complex calculations belong
	   in the driver. I may be wrong.... */
	   in the driver. I may be wrong.... */
	return -ENOSYS;
	return -ENOSYS;
}
}


static int af9005_fe_program_cfoe(struct dvb_usb_device *d, fe_bandwidth_t bw)
static int af9005_fe_program_cfoe(struct dvb_usb_device *d, u32 bw)
{
{
	u8 temp0, temp1, temp2, temp3, buf[4];
	u8 temp0, temp1, temp2, temp3, buf[4];
	int ret;
	int ret;
@@ -551,7 +551,7 @@ static int af9005_fe_program_cfoe(struct dvb_usb_device *d, fe_bandwidth_t bw)
	u32 NS_coeff2_8k;
	u32 NS_coeff2_8k;


	switch (bw) {
	switch (bw) {
	case BANDWIDTH_6_MHZ:
	case 6000000:
		NS_coeff1_2048Nu = 0x2ADB6DC;
		NS_coeff1_2048Nu = 0x2ADB6DC;
		NS_coeff1_8191Nu = 0xAB7313;
		NS_coeff1_8191Nu = 0xAB7313;
		NS_coeff1_8192Nu = 0xAB6DB7;
		NS_coeff1_8192Nu = 0xAB6DB7;
@@ -560,7 +560,7 @@ static int af9005_fe_program_cfoe(struct dvb_usb_device *d, fe_bandwidth_t bw)
		NS_coeff2_8k = 0x55B6DC;
		NS_coeff2_8k = 0x55B6DC;
		break;
		break;


	case BANDWIDTH_7_MHZ:
	case 7000000:
		NS_coeff1_2048Nu = 0x3200001;
		NS_coeff1_2048Nu = 0x3200001;
		NS_coeff1_8191Nu = 0xC80640;
		NS_coeff1_8191Nu = 0xC80640;
		NS_coeff1_8192Nu = 0xC80000;
		NS_coeff1_8192Nu = 0xC80000;
@@ -569,7 +569,7 @@ static int af9005_fe_program_cfoe(struct dvb_usb_device *d, fe_bandwidth_t bw)
		NS_coeff2_8k = 0x640000;
		NS_coeff2_8k = 0x640000;
		break;
		break;


	case BANDWIDTH_8_MHZ:
	case 8000000:
		NS_coeff1_2048Nu = 0x3924926;
		NS_coeff1_2048Nu = 0x3924926;
		NS_coeff1_8191Nu = 0xE4996E;
		NS_coeff1_8191Nu = 0xE4996E;
		NS_coeff1_8192Nu = 0xE49249;
		NS_coeff1_8192Nu = 0xE49249;
@@ -773,17 +773,17 @@ static int af9005_fe_program_cfoe(struct dvb_usb_device *d, fe_bandwidth_t bw)


}
}


static int af9005_fe_select_bw(struct dvb_usb_device *d, fe_bandwidth_t bw)
static int af9005_fe_select_bw(struct dvb_usb_device *d, u32 bw)
{
{
	u8 temp;
	u8 temp;
	switch (bw) {
	switch (bw) {
	case BANDWIDTH_6_MHZ:
	case 6000000:
		temp = 0;
		temp = 0;
		break;
		break;
	case BANDWIDTH_7_MHZ:
	case 7000000:
		temp = 1;
		temp = 1;
		break;
		break;
	case BANDWIDTH_8_MHZ:
	case 8000000:
		temp = 2;
		temp = 2;
		break;
		break;
	default:
	default:
@@ -930,10 +930,11 @@ static int af9005_fe_init(struct dvb_frontend *fe)


	/* init other parameters: program cfoe and select bandwidth */
	/* init other parameters: program cfoe and select bandwidth */
	deb_info("program cfoe\n");
	deb_info("program cfoe\n");
	if ((ret = af9005_fe_program_cfoe(state->d, BANDWIDTH_6_MHZ)))
	ret = af9005_fe_program_cfoe(state->d, 6000000);
	if (ret)
		return ret;
		return ret;
	/* set read-update bit for constellation */
	/* set read-update bit for modulation */
	deb_info("set read-update bit for constellation\n");
	deb_info("set read-update bit for modulation\n");
	if ((ret =
	if ((ret =
	     af9005_write_register_bits(state->d, xd_p_reg_feq_read_update,
	     af9005_write_register_bits(state->d, xd_p_reg_feq_read_update,
					reg_feq_read_update_pos,
					reg_feq_read_update_pos,
@@ -943,8 +944,8 @@ static int af9005_fe_init(struct dvb_frontend *fe)
	/* sample code has a set MPEG TS code here
	/* sample code has a set MPEG TS code here
	   but sniffing reveals that it doesn't do it */
	   but sniffing reveals that it doesn't do it */


	/* set read-update bit to 1 for DCA constellation */
	/* set read-update bit to 1 for DCA modulation */
	deb_info("set read-update bit 1 for DCA constellation\n");
	deb_info("set read-update bit 1 for DCA modulation\n");
	if ((ret =
	if ((ret =
	     af9005_write_register_bits(state->d, xd_p_reg_dca_read_update,
	     af9005_write_register_bits(state->d, xd_p_reg_dca_read_update,
					reg_dca_read_update_pos,
					reg_dca_read_update_pos,
@@ -1099,15 +1100,15 @@ static int af9005_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
	return 0;
	return 0;
}
}


static int af9005_fe_set_frontend(struct dvb_frontend *fe,
static int af9005_fe_set_frontend(struct dvb_frontend *fe)
				  struct dvb_frontend_parameters *fep)
{
{
	struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
	struct af9005_fe_state *state = fe->demodulator_priv;
	struct af9005_fe_state *state = fe->demodulator_priv;
	int ret;
	int ret;
	u8 temp, temp0, temp1, temp2;
	u8 temp, temp0, temp1, temp2;


	deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency,
	deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency,
		 fep->u.ofdm.bandwidth);
		 fep->bandwidth_hz);
	if (fe->ops.tuner_ops.release == NULL) {
	if (fe->ops.tuner_ops.release == NULL) {
		err("Tuner not attached");
		err("Tuner not attached");
		return -ENODEV;
		return -ENODEV;
@@ -1167,10 +1168,10 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe,


	/* select bandwidth */
	/* select bandwidth */
	deb_info("select bandwidth");
	deb_info("select bandwidth");
	ret = af9005_fe_select_bw(state->d, fep->u.ofdm.bandwidth);
	ret = af9005_fe_select_bw(state->d, fep->bandwidth_hz);
	if (ret)
	if (ret)
		return ret;
		return ret;
	ret = af9005_fe_program_cfoe(state->d, fep->u.ofdm.bandwidth);
	ret = af9005_fe_program_cfoe(state->d, fep->bandwidth_hz);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -1226,7 +1227,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe,
}
}


static int af9005_fe_get_frontend(struct dvb_frontend *fe,
static int af9005_fe_get_frontend(struct dvb_frontend *fe,
				  struct dvb_frontend_parameters *fep)
				  struct dtv_frontend_properties *fep)
{
{
	struct af9005_fe_state *state = fe->demodulator_priv;
	struct af9005_fe_state *state = fe->demodulator_priv;
	int ret;
	int ret;
@@ -1243,15 +1244,15 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("CONSTELLATION ");
	deb_info("CONSTELLATION ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.constellation = QPSK;
		fep->modulation = QPSK;
		deb_info("QPSK\n");
		deb_info("QPSK\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.constellation = QAM_16;
		fep->modulation = QAM_16;
		deb_info("QAM_16\n");
		deb_info("QAM_16\n");
		break;
		break;
	case 2:
	case 2:
		fep->u.ofdm.constellation = QAM_64;
		fep->modulation = QAM_64;
		deb_info("QAM_64\n");
		deb_info("QAM_64\n");
		break;
		break;
	}
	}
@@ -1266,19 +1267,19 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("HIERARCHY ");
	deb_info("HIERARCHY ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.hierarchy_information = HIERARCHY_NONE;
		fep->hierarchy = HIERARCHY_NONE;
		deb_info("NONE\n");
		deb_info("NONE\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.hierarchy_information = HIERARCHY_1;
		fep->hierarchy = HIERARCHY_1;
		deb_info("1\n");
		deb_info("1\n");
		break;
		break;
	case 2:
	case 2:
		fep->u.ofdm.hierarchy_information = HIERARCHY_2;
		fep->hierarchy = HIERARCHY_2;
		deb_info("2\n");
		deb_info("2\n");
		break;
		break;
	case 3:
	case 3:
		fep->u.ofdm.hierarchy_information = HIERARCHY_4;
		fep->hierarchy = HIERARCHY_4;
		deb_info("4\n");
		deb_info("4\n");
		break;
		break;
	}
	}
@@ -1302,23 +1303,23 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("CODERATE HP ");
	deb_info("CODERATE HP ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.code_rate_HP = FEC_1_2;
		fep->code_rate_HP = FEC_1_2;
		deb_info("FEC_1_2\n");
		deb_info("FEC_1_2\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.code_rate_HP = FEC_2_3;
		fep->code_rate_HP = FEC_2_3;
		deb_info("FEC_2_3\n");
		deb_info("FEC_2_3\n");
		break;
		break;
	case 2:
	case 2:
		fep->u.ofdm.code_rate_HP = FEC_3_4;
		fep->code_rate_HP = FEC_3_4;
		deb_info("FEC_3_4\n");
		deb_info("FEC_3_4\n");
		break;
		break;
	case 3:
	case 3:
		fep->u.ofdm.code_rate_HP = FEC_5_6;
		fep->code_rate_HP = FEC_5_6;
		deb_info("FEC_5_6\n");
		deb_info("FEC_5_6\n");
		break;
		break;
	case 4:
	case 4:
		fep->u.ofdm.code_rate_HP = FEC_7_8;
		fep->code_rate_HP = FEC_7_8;
		deb_info("FEC_7_8\n");
		deb_info("FEC_7_8\n");
		break;
		break;
	}
	}
@@ -1333,23 +1334,23 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("CODERATE LP ");
	deb_info("CODERATE LP ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.code_rate_LP = FEC_1_2;
		fep->code_rate_LP = FEC_1_2;
		deb_info("FEC_1_2\n");
		deb_info("FEC_1_2\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.code_rate_LP = FEC_2_3;
		fep->code_rate_LP = FEC_2_3;
		deb_info("FEC_2_3\n");
		deb_info("FEC_2_3\n");
		break;
		break;
	case 2:
	case 2:
		fep->u.ofdm.code_rate_LP = FEC_3_4;
		fep->code_rate_LP = FEC_3_4;
		deb_info("FEC_3_4\n");
		deb_info("FEC_3_4\n");
		break;
		break;
	case 3:
	case 3:
		fep->u.ofdm.code_rate_LP = FEC_5_6;
		fep->code_rate_LP = FEC_5_6;
		deb_info("FEC_5_6\n");
		deb_info("FEC_5_6\n");
		break;
		break;
	case 4:
	case 4:
		fep->u.ofdm.code_rate_LP = FEC_7_8;
		fep->code_rate_LP = FEC_7_8;
		deb_info("FEC_7_8\n");
		deb_info("FEC_7_8\n");
		break;
		break;
	}
	}
@@ -1363,19 +1364,19 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("GUARD INTERVAL ");
	deb_info("GUARD INTERVAL ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
		fep->guard_interval = GUARD_INTERVAL_1_32;
		deb_info("1_32\n");
		deb_info("1_32\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
		fep->guard_interval = GUARD_INTERVAL_1_16;
		deb_info("1_16\n");
		deb_info("1_16\n");
		break;
		break;
	case 2:
	case 2:
		fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
		fep->guard_interval = GUARD_INTERVAL_1_8;
		deb_info("1_8\n");
		deb_info("1_8\n");
		break;
		break;
	case 3:
	case 3:
		fep->u.ofdm.guard_interval = GUARD_INTERVAL_1_4;
		fep->guard_interval = GUARD_INTERVAL_1_4;
		deb_info("1_4\n");
		deb_info("1_4\n");
		break;
		break;
	}
	}
@@ -1390,11 +1391,11 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("TRANSMISSION MODE ");
	deb_info("TRANSMISSION MODE ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
		fep->transmission_mode = TRANSMISSION_MODE_2K;
		deb_info("2K\n");
		deb_info("2K\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
		fep->transmission_mode = TRANSMISSION_MODE_8K;
		deb_info("8K\n");
		deb_info("8K\n");
		break;
		break;
	}
	}
@@ -1406,15 +1407,15 @@ static int af9005_fe_get_frontend(struct dvb_frontend *fe,
	deb_info("BANDWIDTH ");
	deb_info("BANDWIDTH ");
	switch (temp) {
	switch (temp) {
	case 0:
	case 0:
		fep->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
		fep->bandwidth_hz = 6000000;
		deb_info("6\n");
		deb_info("6\n");
		break;
		break;
	case 1:
	case 1:
		fep->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
		fep->bandwidth_hz = 7000000;
		deb_info("7\n");
		deb_info("7\n");
		break;
		break;
	case 2:
	case 2:
		fep->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
		fep->bandwidth_hz = 8000000;
		deb_info("8\n");
		deb_info("8\n");
		break;
		break;
	}
	}
@@ -1454,6 +1455,7 @@ struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d)
}
}


static struct dvb_frontend_ops af9005_fe_ops = {
static struct dvb_frontend_ops af9005_fe_ops = {
	.delsys = { SYS_DVBT },
	.info = {
	.info = {
		 .name = "AF9005 USB DVB-T",
		 .name = "AF9005 USB DVB-T",
		 .type = FE_OFDM,
		 .type = FE_OFDM,
@@ -1475,8 +1477,8 @@ static struct dvb_frontend_ops af9005_fe_ops = {
	.sleep = af9005_fe_sleep,
	.sleep = af9005_fe_sleep,
	.ts_bus_ctrl = af9005_ts_bus_ctrl,
	.ts_bus_ctrl = af9005_ts_bus_ctrl,


	.set_frontend_legacy = af9005_fe_set_frontend,
	.set_frontend = af9005_fe_set_frontend,
	.get_frontend_legacy = af9005_fe_get_frontend,
	.get_frontend = af9005_fe_get_frontend,


	.read_status = af9005_fe_read_status,
	.read_status = af9005_fe_read_status,
	.read_ber = af9005_fe_read_ber,
	.read_ber = af9005_fe_read_ber,