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

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

[media] staging/as102: 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 f6c69968
Loading
Loading
Loading
Loading
+39 −39
Original line number Original line Diff line number Diff line
@@ -23,15 +23,15 @@
#include "as10x_types.h"
#include "as10x_types.h"
#include "as10x_cmd.h"
#include "as10x_cmd.h"


static void as10x_fe_copy_tps_parameters(struct dvb_frontend_parameters *dst,
static void as10x_fe_copy_tps_parameters(struct dtv_frontend_properties *dst,
					 struct as10x_tps *src);
					 struct as10x_tps *src);


static void as102_fe_copy_tune_parameters(struct as10x_tune_args *dst,
static void as102_fe_copy_tune_parameters(struct as10x_tune_args *dst,
					  struct dvb_frontend_parameters *src);
					  struct dtv_frontend_properties *src);


static int as102_fe_set_frontend(struct dvb_frontend *fe,
static int as102_fe_set_frontend(struct dvb_frontend *fe)
				 struct dvb_frontend_parameters *params)
{
{
	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
	int ret = 0;
	int ret = 0;
	struct as102_dev_t *dev;
	struct as102_dev_t *dev;
	struct as10x_tune_args tune_args = { 0 };
	struct as10x_tune_args tune_args = { 0 };
@@ -45,7 +45,7 @@ static int as102_fe_set_frontend(struct dvb_frontend *fe,
	if (mutex_lock_interruptible(&dev->bus_adap.lock))
	if (mutex_lock_interruptible(&dev->bus_adap.lock))
		return -EBUSY;
		return -EBUSY;


	as102_fe_copy_tune_parameters(&tune_args, params);
	as102_fe_copy_tune_parameters(&tune_args, p);


	/* send abilis command: SET_TUNE */
	/* send abilis command: SET_TUNE */
	ret =  as10x_cmd_set_tune(&dev->bus_adap, &tune_args);
	ret =  as10x_cmd_set_tune(&dev->bus_adap, &tune_args);
@@ -59,7 +59,8 @@ static int as102_fe_set_frontend(struct dvb_frontend *fe,
}
}


static int as102_fe_get_frontend(struct dvb_frontend *fe,
static int as102_fe_get_frontend(struct dvb_frontend *fe,
				 struct dvb_frontend_parameters *p) {
				 struct dtv_frontend_properties *p)
{
	int ret = 0;
	int ret = 0;
	struct as102_dev_t *dev;
	struct as102_dev_t *dev;
	struct as10x_tps tps = { 0 };
	struct as10x_tps tps = { 0 };
@@ -278,6 +279,7 @@ static int as102_fe_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
}
}


static struct dvb_frontend_ops as102_fe_ops = {
static struct dvb_frontend_ops as102_fe_ops = {
	.delsys = { SYS_DVBT },
	.info = {
	.info = {
		.name			= "Unknown AS102 device",
		.name			= "Unknown AS102 device",
		.type			= FE_OFDM,
		.type			= FE_OFDM,
@@ -296,8 +298,8 @@ static struct dvb_frontend_ops as102_fe_ops = {
			| FE_CAN_MUTE_TS
			| FE_CAN_MUTE_TS
	},
	},


	.set_frontend_legacy	= as102_fe_set_frontend,
	.set_frontend		= as102_fe_set_frontend,
	.get_frontend_legacy	= as102_fe_get_frontend,
	.get_frontend		= as102_fe_get_frontend,
	.get_tune_settings	= as102_fe_get_tune_settings,
	.get_tune_settings	= as102_fe_get_tune_settings,


	.read_status		= as102_fe_read_status,
	.read_status		= as102_fe_read_status,
@@ -344,38 +346,36 @@ int as102_dvb_register_fe(struct as102_dev_t *as102_dev,
	return errno;
	return errno;
}
}


static void as10x_fe_copy_tps_parameters(struct dvb_frontend_parameters *dst,
static void as10x_fe_copy_tps_parameters(struct dtv_frontend_properties *fe_tps,
					 struct as10x_tps *as10x_tps)
					 struct as10x_tps *as10x_tps)
{
{


	struct dvb_ofdm_parameters *fe_tps = &dst->u.ofdm;

	/* extract consteallation */
	/* extract consteallation */
	switch (as10x_tps->constellation) {
	switch (as10x_tps->modulation) {
	case CONST_QPSK:
	case CONST_QPSK:
		fe_tps->constellation = QPSK;
		fe_tps->modulation = QPSK;
		break;
		break;
	case CONST_QAM16:
	case CONST_QAM16:
		fe_tps->constellation = QAM_16;
		fe_tps->modulation = QAM_16;
		break;
		break;
	case CONST_QAM64:
	case CONST_QAM64:
		fe_tps->constellation = QAM_64;
		fe_tps->modulation = QAM_64;
		break;
		break;
	}
	}


	/* extract hierarchy */
	/* extract hierarchy */
	switch (as10x_tps->hierarchy) {
	switch (as10x_tps->hierarchy) {
	case HIER_NONE:
	case HIER_NONE:
		fe_tps->hierarchy_information = HIERARCHY_NONE;
		fe_tps->hierarchy = HIERARCHY_NONE;
		break;
		break;
	case HIER_ALPHA_1:
	case HIER_ALPHA_1:
		fe_tps->hierarchy_information = HIERARCHY_1;
		fe_tps->hierarchy = HIERARCHY_1;
		break;
		break;
	case HIER_ALPHA_2:
	case HIER_ALPHA_2:
		fe_tps->hierarchy_information = HIERARCHY_2;
		fe_tps->hierarchy = HIERARCHY_2;
		break;
		break;
	case HIER_ALPHA_4:
	case HIER_ALPHA_4:
		fe_tps->hierarchy_information = HIERARCHY_4;
		fe_tps->hierarchy = HIERARCHY_4;
		break;
		break;
	}
	}


@@ -473,7 +473,7 @@ static uint8_t as102_fe_get_code_rate(fe_code_rate_t arg)
}
}


static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
			  struct dvb_frontend_parameters *params)
			  struct dtv_frontend_properties *params)
{
{


	/* set frequency */
	/* set frequency */
@@ -482,21 +482,21 @@ static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
	/* fix interleaving_mode */
	/* fix interleaving_mode */
	tune_args->interleaving_mode = INTLV_NATIVE;
	tune_args->interleaving_mode = INTLV_NATIVE;


	switch (params->u.ofdm.bandwidth) {
	switch (params->bandwidth_hz) {
	case BANDWIDTH_8_MHZ:
	case 8000000:
		tune_args->bandwidth = BW_8_MHZ;
		tune_args->bandwidth = BW_8_MHZ;
		break;
		break;
	case BANDWIDTH_7_MHZ:
	case 7000000:
		tune_args->bandwidth = BW_7_MHZ;
		tune_args->bandwidth = BW_7_MHZ;
		break;
		break;
	case BANDWIDTH_6_MHZ:
	case 6000000:
		tune_args->bandwidth = BW_6_MHZ;
		tune_args->bandwidth = BW_6_MHZ;
		break;
		break;
	default:
	default:
		tune_args->bandwidth = BW_8_MHZ;
		tune_args->bandwidth = BW_8_MHZ;
	}
	}


	switch (params->u.ofdm.guard_interval) {
	switch (params->guard_interval) {
	case GUARD_INTERVAL_1_32:
	case GUARD_INTERVAL_1_32:
		tune_args->guard_interval = GUARD_INT_1_32;
		tune_args->guard_interval = GUARD_INT_1_32;
		break;
		break;
@@ -515,22 +515,22 @@ static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
		break;
		break;
	}
	}


	switch (params->u.ofdm.constellation) {
	switch (params->modulation) {
	case QPSK:
	case QPSK:
		tune_args->constellation = CONST_QPSK;
		tune_args->modulation = CONST_QPSK;
		break;
		break;
	case QAM_16:
	case QAM_16:
		tune_args->constellation = CONST_QAM16;
		tune_args->modulation = CONST_QAM16;
		break;
		break;
	case QAM_64:
	case QAM_64:
		tune_args->constellation = CONST_QAM64;
		tune_args->modulation = CONST_QAM64;
		break;
		break;
	default:
	default:
		tune_args->constellation = CONST_UNKNOWN;
		tune_args->modulation = CONST_UNKNOWN;
		break;
		break;
	}
	}


	switch (params->u.ofdm.transmission_mode) {
	switch (params->transmission_mode) {
	case TRANSMISSION_MODE_2K:
	case TRANSMISSION_MODE_2K:
		tune_args->transmission_mode = TRANS_MODE_2K;
		tune_args->transmission_mode = TRANS_MODE_2K;
		break;
		break;
@@ -541,7 +541,7 @@ static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
		tune_args->transmission_mode = TRANS_MODE_UNKNOWN;
		tune_args->transmission_mode = TRANS_MODE_UNKNOWN;
	}
	}


	switch (params->u.ofdm.hierarchy_information) {
	switch (params->hierarchy) {
	case HIERARCHY_NONE:
	case HIERARCHY_NONE:
		tune_args->hierarchy = HIER_NONE;
		tune_args->hierarchy = HIER_NONE;
		break;
		break;
@@ -569,19 +569,19 @@ static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
	 * if HP/LP are both set to FEC_NONE, HP will be selected.
	 * if HP/LP are both set to FEC_NONE, HP will be selected.
	 */
	 */
	if ((tune_args->hierarchy != HIER_NONE) &&
	if ((tune_args->hierarchy != HIER_NONE) &&
		       ((params->u.ofdm.code_rate_LP == FEC_NONE) ||
		       ((params->code_rate_LP == FEC_NONE) ||
			(params->u.ofdm.code_rate_HP == FEC_NONE))) {
			(params->code_rate_HP == FEC_NONE))) {


		if (params->u.ofdm.code_rate_LP == FEC_NONE) {
		if (params->code_rate_LP == FEC_NONE) {
			tune_args->hier_select = HIER_HIGH_PRIORITY;
			tune_args->hier_select = HIER_HIGH_PRIORITY;
			tune_args->code_rate =
			tune_args->code_rate =
			   as102_fe_get_code_rate(params->u.ofdm.code_rate_HP);
			   as102_fe_get_code_rate(params->code_rate_HP);
		}
		}


		if (params->u.ofdm.code_rate_HP == FEC_NONE) {
		if (params->code_rate_HP == FEC_NONE) {
			tune_args->hier_select = HIER_LOW_PRIORITY;
			tune_args->hier_select = HIER_LOW_PRIORITY;
			tune_args->code_rate =
			tune_args->code_rate =
			   as102_fe_get_code_rate(params->u.ofdm.code_rate_LP);
			   as102_fe_get_code_rate(params->code_rate_LP);
		}
		}


		dprintk(debug, "\thierarchy: 0x%02x  "
		dprintk(debug, "\thierarchy: 0x%02x  "
@@ -594,6 +594,6 @@ static void as102_fe_copy_tune_parameters(struct as10x_tune_args *tune_args,
			tune_args->code_rate);
			tune_args->code_rate);
	} else {
	} else {
		tune_args->code_rate =
		tune_args->code_rate =
			as102_fe_get_code_rate(params->u.ofdm.code_rate_HP);
			as102_fe_get_code_rate(params->code_rate_HP);
	}
	}
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -141,7 +141,7 @@ int as10x_cmd_set_tune(struct as10x_bus_adapter_t *adap,
	preq->body.set_tune.req.args.freq = cpu_to_le32(ptune->freq);
	preq->body.set_tune.req.args.freq = cpu_to_le32(ptune->freq);
	preq->body.set_tune.req.args.bandwidth = ptune->bandwidth;
	preq->body.set_tune.req.args.bandwidth = ptune->bandwidth;
	preq->body.set_tune.req.args.hier_select = ptune->hier_select;
	preq->body.set_tune.req.args.hier_select = ptune->hier_select;
	preq->body.set_tune.req.args.constellation = ptune->constellation;
	preq->body.set_tune.req.args.modulation = ptune->modulation;
	preq->body.set_tune.req.args.hierarchy = ptune->hierarchy;
	preq->body.set_tune.req.args.hierarchy = ptune->hierarchy;
	preq->body.set_tune.req.args.interleaving_mode  =
	preq->body.set_tune.req.args.interleaving_mode  =
		ptune->interleaving_mode;
		ptune->interleaving_mode;
@@ -279,7 +279,7 @@ int as10x_cmd_get_tps(struct as10x_bus_adapter_t *adap, struct as10x_tps *ptps)
		goto out;
		goto out;


	/* Response OK -> get response data */
	/* Response OK -> get response data */
	ptps->constellation = prsp->body.get_tps.rsp.tps.constellation;
	ptps->modulation = prsp->body.get_tps.rsp.tps.modulation;
	ptps->hierarchy = prsp->body.get_tps.rsp.tps.hierarchy;
	ptps->hierarchy = prsp->body.get_tps.rsp.tps.hierarchy;
	ptps->interleaving_mode = prsp->body.get_tps.rsp.tps.interleaving_mode;
	ptps->interleaving_mode = prsp->body.get_tps.rsp.tps.interleaving_mode;
	ptps->code_rate_HP = prsp->body.get_tps.rsp.tps.code_rate_HP;
	ptps->code_rate_HP = prsp->body.get_tps.rsp.tps.code_rate_HP;
+2 −2
Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@
#define CFG_MODE_AUTO	2
#define CFG_MODE_AUTO	2


struct as10x_tps {
struct as10x_tps {
	uint8_t constellation;
	uint8_t modulation;
	uint8_t hierarchy;
	uint8_t hierarchy;
	uint8_t interleaving_mode;
	uint8_t interleaving_mode;
	uint8_t code_rate_HP;
	uint8_t code_rate_HP;
@@ -132,7 +132,7 @@ struct as10x_tune_args {
	/* hierarchy selection */
	/* hierarchy selection */
	uint8_t hier_select;
	uint8_t hier_select;
	/* constellation */
	/* constellation */
	uint8_t constellation;
	uint8_t modulation;
	/* hierarchy */
	/* hierarchy */
	uint8_t hierarchy;
	uint8_t hierarchy;
	/* interleaving mode */
	/* interleaving mode */