Commit cf4fab72 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (13842): smsdvb: Convert it to use DVB API v5 (S2API)

Based on a patch originally written by Michael Krufky <mkrufky@linuxtv.org>
for a preliminar S2API spec.

The patch were ported to the S2API and had the ISDB-T API additions to
honor the auto mode, while keep allowing manual tuning.

Tested with both the original dvb-apps and the new dvb-apps-isdbt scan,
that uses a different channel.conf and uses S2API with ISDB-T extensions.

Thanks-to: Michael Krufky <mkrufky@linuxtv.org> for his first version
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 67ae1d26
...@@ -478,8 +478,9 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe, ...@@ -478,8 +478,9 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe,
} }
static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *fep) struct dvb_frontend_parameters *p)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct smsdvb_client_t *client = struct smsdvb_client_t *client =
container_of(fe, struct smsdvb_client_t, frontend); container_of(fe, struct smsdvb_client_t, frontend);
...@@ -499,18 +500,26 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, ...@@ -499,18 +500,26 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe,
Msg.Msg.msgFlags = 0; Msg.Msg.msgFlags = 0;
Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ;
Msg.Msg.msgLength = sizeof(Msg); Msg.Msg.msgLength = sizeof(Msg);
Msg.Data[0] = fep->frequency; Msg.Data[0] = c->frequency;
Msg.Data[2] = 12000000; Msg.Data[2] = 12000000;
sms_debug("freq %d band %d", sms_info("%s: freq %d band %d", __func__, c->frequency,
fep->frequency, fep->u.ofdm.bandwidth); c->bandwidth_hz);
switch (fep->u.ofdm.bandwidth) { switch (c->bandwidth_hz / 1000) {
case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; case 8:
case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; Msg.Data[1] = BW_8_MHZ;
case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; break;
case BANDWIDTH_AUTO: return -EOPNOTSUPP; case 7:
default: return -EINVAL; Msg.Data[1] = BW_7_MHZ;
break;
case 6:
Msg.Data[1] = BW_6_MHZ;
break;
case 0:
return -EOPNOTSUPP;
default:
return -EINVAL;
} }
/* Disable LNA, if any. An error is returned if no LNA is present */ /* Disable LNA, if any. An error is returned if no LNA is present */
ret = sms_board_lna_control(client->coredev, 0); ret = sms_board_lna_control(client->coredev, 0);
...@@ -535,9 +544,9 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, ...@@ -535,9 +544,9 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe,
} }
static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe, static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *fep, struct dvb_frontend_parameters *p)
u32 SegmentNumber)
{ {
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct smsdvb_client_t *client = struct smsdvb_client_t *client =
container_of(fe, struct smsdvb_client_t, frontend); container_of(fe, struct smsdvb_client_t, frontend);
...@@ -551,29 +560,48 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe, ...@@ -551,29 +560,48 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe,
Msg.Msg.msgFlags = 0; Msg.Msg.msgFlags = 0;
Msg.Msg.msgType = MSG_SMS_ISDBT_TUNE_REQ; Msg.Msg.msgType = MSG_SMS_ISDBT_TUNE_REQ;
Msg.Msg.msgLength = sizeof(Msg); Msg.Msg.msgLength = sizeof(Msg);
Msg.Data[0] = fep->frequency;
Msg.Data[2] = 12000000;
Msg.Data[3] = SegmentNumber;
sms_debug("freq %d band %d seg %d\n", if (c->isdbt_sb_segment_idx == -1)
fep->frequency, fep->u.ofdm.bandwidth, SegmentNumber); c->isdbt_sb_segment_idx = 0;
switch (fep->u.ofdm.bandwidth) { switch (c->isdbt_sb_segment_count) {
case BANDWIDTH_8_MHZ: case 3:
Msg.Data[1] = BW_ISDBT_3SEG; Msg.Data[1] = BW_ISDBT_3SEG;
break; break;
case BANDWIDTH_7_MHZ: case 1:
Msg.Data[1] = BW_ISDBT_3SEG;
break;
case BANDWIDTH_6_MHZ:
Msg.Data[1] = BW_ISDBT_1SEG; Msg.Data[1] = BW_ISDBT_1SEG;
break; break;
case BANDWIDTH_AUTO: case 0: /* AUTO */
return -EOPNOTSUPP; switch (c->bandwidth_hz / 1000) {
case 8:
case 7:
c->isdbt_sb_segment_count = 3;
Msg.Data[1] = BW_ISDBT_3SEG;
break;
case 6:
c->isdbt_sb_segment_count = 1;
Msg.Data[1] = BW_ISDBT_1SEG;
break;
default: /* Assumes 6 MHZ bw */
c->isdbt_sb_segment_count = 1;
c->bandwidth_hz = 6000;
Msg.Data[1] = BW_ISDBT_1SEG;
break;
}
break;
default: default:
sms_info("Segment count %d not supported", c->isdbt_sb_segment_count);
return -EINVAL; return -EINVAL;
} }
Msg.Data[0] = c->frequency;
Msg.Data[2] = 12000000;
Msg.Data[3] = c->isdbt_sb_segment_idx;
sms_info("%s: freq %d segwidth %d segindex %d\n", __func__,
c->frequency, c->isdbt_sb_segment_count,
c->isdbt_sb_segment_idx);
return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
&client->tune_done); &client->tune_done);
} }
...@@ -591,13 +619,7 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, ...@@ -591,13 +619,7 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe,
return smsdvb_dvbt_set_frontend(fe, fep); return smsdvb_dvbt_set_frontend(fe, fep);
case DEVICE_MODE_ISDBT: case DEVICE_MODE_ISDBT:
case DEVICE_MODE_ISDBT_BDA: case DEVICE_MODE_ISDBT_BDA:
{ return smsdvb_isdbt_set_frontend(fe, fep);
u32 segmentnum;
/* XXX: hack - use 4 lower bits in frequency for segment num */
segmentnum = fep->frequency & 0x0000000f;
fep->frequency &= ~0x0000000f;
return smsdvb_isdbt_set_frontend(fe, fep, segmentnum);
}
default: default:
return -EINVAL; return -EINVAL;
} }
......
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