diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-23 09:28:46 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:25 -0500 |
commit | cf4fab720c66b15a6cf3abeb5a38acb841efedf4 (patch) | |
tree | 0d21a266e25cd9c579ec70a2022497309ed3408f /drivers/media/dvb/siano | |
parent | 67ae1d26bd9291280874b49b9f388722682fe58f (diff) |
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: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/siano')
-rw-r--r-- | drivers/media/dvb/siano/smsdvb.c | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c index 6b85b4872f59..3b786de22715 100644 --- a/drivers/media/dvb/siano/smsdvb.c +++ b/drivers/media/dvb/siano/smsdvb.c | |||
@@ -478,8 +478,9 @@ static int smsdvb_get_tune_settings(struct dvb_frontend *fe, | |||
478 | } | 478 | } |
479 | 479 | ||
480 | static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, | 480 | static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, |
481 | struct dvb_frontend_parameters *fep) | 481 | struct dvb_frontend_parameters *p) |
482 | { | 482 | { |
483 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
483 | struct smsdvb_client_t *client = | 484 | struct smsdvb_client_t *client = |
484 | container_of(fe, struct smsdvb_client_t, frontend); | 485 | container_of(fe, struct smsdvb_client_t, frontend); |
485 | 486 | ||
@@ -499,18 +500,26 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, | |||
499 | Msg.Msg.msgFlags = 0; | 500 | Msg.Msg.msgFlags = 0; |
500 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; | 501 | Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ; |
501 | Msg.Msg.msgLength = sizeof(Msg); | 502 | Msg.Msg.msgLength = sizeof(Msg); |
502 | Msg.Data[0] = fep->frequency; | 503 | Msg.Data[0] = c->frequency; |
503 | Msg.Data[2] = 12000000; | 504 | Msg.Data[2] = 12000000; |
504 | 505 | ||
505 | sms_debug("freq %d band %d", | 506 | sms_info("%s: freq %d band %d", __func__, c->frequency, |
506 | fep->frequency, fep->u.ofdm.bandwidth); | 507 | c->bandwidth_hz); |
507 | 508 | ||
508 | switch (fep->u.ofdm.bandwidth) { | 509 | switch (c->bandwidth_hz / 1000) { |
509 | case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break; | 510 | case 8: |
510 | case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break; | 511 | Msg.Data[1] = BW_8_MHZ; |
511 | case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break; | 512 | break; |
512 | case BANDWIDTH_AUTO: return -EOPNOTSUPP; | 513 | case 7: |
513 | default: return -EINVAL; | 514 | Msg.Data[1] = BW_7_MHZ; |
515 | break; | ||
516 | case 6: | ||
517 | Msg.Data[1] = BW_6_MHZ; | ||
518 | break; | ||
519 | case 0: | ||
520 | return -EOPNOTSUPP; | ||
521 | default: | ||
522 | return -EINVAL; | ||
514 | } | 523 | } |
515 | /* Disable LNA, if any. An error is returned if no LNA is present */ | 524 | /* Disable LNA, if any. An error is returned if no LNA is present */ |
516 | ret = sms_board_lna_control(client->coredev, 0); | 525 | ret = sms_board_lna_control(client->coredev, 0); |
@@ -535,9 +544,9 @@ static int smsdvb_dvbt_set_frontend(struct dvb_frontend *fe, | |||
535 | } | 544 | } |
536 | 545 | ||
537 | static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe, | 546 | static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe, |
538 | struct dvb_frontend_parameters *fep, | 547 | struct dvb_frontend_parameters *p) |
539 | u32 SegmentNumber) | ||
540 | { | 548 | { |
549 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
541 | struct smsdvb_client_t *client = | 550 | struct smsdvb_client_t *client = |
542 | container_of(fe, struct smsdvb_client_t, frontend); | 551 | container_of(fe, struct smsdvb_client_t, frontend); |
543 | 552 | ||
@@ -551,29 +560,48 @@ static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe, | |||
551 | Msg.Msg.msgFlags = 0; | 560 | Msg.Msg.msgFlags = 0; |
552 | Msg.Msg.msgType = MSG_SMS_ISDBT_TUNE_REQ; | 561 | Msg.Msg.msgType = MSG_SMS_ISDBT_TUNE_REQ; |
553 | Msg.Msg.msgLength = sizeof(Msg); | 562 | Msg.Msg.msgLength = sizeof(Msg); |
554 | Msg.Data[0] = fep->frequency; | ||
555 | Msg.Data[2] = 12000000; | ||
556 | Msg.Data[3] = SegmentNumber; | ||
557 | 563 | ||
558 | sms_debug("freq %d band %d seg %d\n", | 564 | if (c->isdbt_sb_segment_idx == -1) |
559 | fep->frequency, fep->u.ofdm.bandwidth, SegmentNumber); | 565 | c->isdbt_sb_segment_idx = 0; |
560 | 566 | ||
561 | switch (fep->u.ofdm.bandwidth) { | 567 | switch (c->isdbt_sb_segment_count) { |
562 | case BANDWIDTH_8_MHZ: | 568 | case 3: |
563 | Msg.Data[1] = BW_ISDBT_3SEG; | 569 | Msg.Data[1] = BW_ISDBT_3SEG; |
564 | break; | 570 | break; |
565 | case BANDWIDTH_7_MHZ: | 571 | case 1: |
566 | Msg.Data[1] = BW_ISDBT_3SEG; | ||
567 | break; | ||
568 | case BANDWIDTH_6_MHZ: | ||
569 | Msg.Data[1] = BW_ISDBT_1SEG; | 572 | Msg.Data[1] = BW_ISDBT_1SEG; |
570 | break; | 573 | break; |
571 | case BANDWIDTH_AUTO: | 574 | case 0: /* AUTO */ |
572 | return -EOPNOTSUPP; | 575 | switch (c->bandwidth_hz / 1000) { |
576 | case 8: | ||
577 | case 7: | ||
578 | c->isdbt_sb_segment_count = 3; | ||
579 | Msg.Data[1] = BW_ISDBT_3SEG; | ||
580 | break; | ||
581 | case 6: | ||
582 | c->isdbt_sb_segment_count = 1; | ||
583 | Msg.Data[1] = BW_ISDBT_1SEG; | ||
584 | break; | ||
585 | default: /* Assumes 6 MHZ bw */ | ||
586 | c->isdbt_sb_segment_count = 1; | ||
587 | c->bandwidth_hz = 6000; | ||
588 | Msg.Data[1] = BW_ISDBT_1SEG; | ||
589 | break; | ||
590 | } | ||
591 | break; | ||
573 | default: | 592 | default: |
593 | sms_info("Segment count %d not supported", c->isdbt_sb_segment_count); | ||
574 | return -EINVAL; | 594 | return -EINVAL; |
575 | } | 595 | } |
576 | 596 | ||
597 | Msg.Data[0] = c->frequency; | ||
598 | Msg.Data[2] = 12000000; | ||
599 | Msg.Data[3] = c->isdbt_sb_segment_idx; | ||
600 | |||
601 | sms_info("%s: freq %d segwidth %d segindex %d\n", __func__, | ||
602 | c->frequency, c->isdbt_sb_segment_count, | ||
603 | c->isdbt_sb_segment_idx); | ||
604 | |||
577 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), | 605 | return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), |
578 | &client->tune_done); | 606 | &client->tune_done); |
579 | } | 607 | } |
@@ -591,13 +619,7 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe, | |||
591 | return smsdvb_dvbt_set_frontend(fe, fep); | 619 | return smsdvb_dvbt_set_frontend(fe, fep); |
592 | case DEVICE_MODE_ISDBT: | 620 | case DEVICE_MODE_ISDBT: |
593 | case DEVICE_MODE_ISDBT_BDA: | 621 | case DEVICE_MODE_ISDBT_BDA: |
594 | { | 622 | return smsdvb_isdbt_set_frontend(fe, fep); |
595 | u32 segmentnum; | ||
596 | /* XXX: hack - use 4 lower bits in frequency for segment num */ | ||
597 | segmentnum = fep->frequency & 0x0000000f; | ||
598 | fep->frequency &= ~0x0000000f; | ||
599 | return smsdvb_isdbt_set_frontend(fe, fep, segmentnum); | ||
600 | } | ||
601 | default: | 623 | default: |
602 | return -EINVAL; | 624 | return -EINVAL; |
603 | } | 625 | } |