The patch number 13874 was added via Jean-Francois Moine <moin...@free.fr>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <linux-me...@vger.kernel.org>

------

merge: v4l-dvb


---

 linux/drivers/media/dvb/frontends/dib8000.c |    2 
 linux/drivers/media/dvb/siano/smscoreapi.h  |   77 +++++
 linux/drivers/media/dvb/siano/smsdvb.c      |  290 ++++++++++++++++----
 3 files changed, 322 insertions(+), 47 deletions(-)

diff -r ac3e520a01e1 -r 786efa7be8db linux/drivers/media/dvb/frontends/dib8000.c
--- a/linux/drivers/media/dvb/frontends/dib8000.c       Wed Dec 23 08:48:18 
2009 +0100
+++ b/linux/drivers/media/dvb/frontends/dib8000.c       Sat Dec 26 12:42:17 
2009 +0100
@@ -2000,6 +2000,8 @@
        struct dib8000_state *state = fe->demodulator_priv;
        int time, ret;
 
+       fe->dtv_property_cache.delivery_system = SYS_ISDBT;
+
        dib8000_set_output_mode(state, OUTMODE_HIGH_Z);
 
        if (fe->ops.tuner_ops.set_params)
diff -r ac3e520a01e1 -r 786efa7be8db linux/drivers/media/dvb/siano/smscoreapi.h
--- a/linux/drivers/media/dvb/siano/smscoreapi.h        Wed Dec 23 08:48:18 
2009 +0100
+++ b/linux/drivers/media/dvb/siano/smscoreapi.h        Sat Dec 26 12:42:17 
2009 +0100
@@ -213,6 +213,8 @@
 #define MSG_SMS_DAB_CHANNEL                            607
 #define MSG_SMS_GET_PID_FILTER_LIST_REQ                        608
 #define MSG_SMS_GET_PID_FILTER_LIST_RES                        609
+#define MSG_SMS_GET_STATISTICS_RES                     616
+#define MSG_SMS_GET_STATISTICS_REQ                     615
 #define MSG_SMS_HO_PER_SLICES_IND                      630
 #define MSG_SMS_SET_ANTENNA_CONFIG_REQ                 651
 #define MSG_SMS_SET_ANTENNA_CONFIG_RES                 652
@@ -340,7 +342,7 @@
 
 /* Statistics information returned as response for
  * SmsHostApiGetStatistics_Req */
-struct SMSHOSTLIB_STATISTICS_S {
+struct SMSHOSTLIB_STATISTICS_ST {
        u32 Reserved;           /* Reserved */
 
        /* Common parameters */
@@ -425,6 +427,79 @@
        u32 ReservedFields[10]; /* Reserved */
 };
 
+struct SmsMsgStatisticsInfo_ST {
+       u32 RequestResult;
+
+       struct SMSHOSTLIB_STATISTICS_ST Stat;
+
+       /* Split the calc of the SNR in DAB */
+       u32 Signal; /* dB */
+       u32 Noise; /* dB */
+
+};
+
+struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST {
+       /* Per-layer information */
+       u32 CodeRate; /* Code Rate from SMSHOSTLIB_CODE_RATE_ET,
+                      * 255 means layer does not exist */
+       u32 Constellation; /* Constellation from SMSHOSTLIB_CONSTELLATION_ET,
+                           * 255 means layer does not exist */
+       u32 BER; /* Post Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
+       u32 BERErrorCount; /* Post Viterbi Error Bits Count */
+       u32 BERBitCount; /* Post Viterbi Total Bits Count */
+       u32 PreBER; /* Pre Viterbi BER [1E-5], 0xFFFFFFFF indicate N/A */
+       u32 TS_PER; /* Transport stream PER [%], 0xFFFFFFFF indicate N/A */
+       u32 ErrorTSPackets; /* Number of erroneous transport-stream packets */
+       u32 TotalTSPackets; /* Total number of transport-stream packets */
+       u32 TILdepthI; /* Time interleaver depth I parameter,
+                       * 255 means layer does not exist */
+       u32 NumberOfSegments; /* Number of segments in layer A,
+                              * 255 means layer does not exist */
+       u32 TMCCErrors; /* TMCC errors */
+};
+
+struct SMSHOSTLIB_STATISTICS_ISDBT_ST {
+       u32 StatisticsType; /* Enumerator identifying the type of the
+                               * structure.  Values are the same as
+                               * SMSHOSTLIB_DEVICE_MODES_E
+                               *
+                               * This field MUST always be first in any
+                               * statistics structure */
+
+       u32 FullSize; /* Total size of the structure returned by the modem.
+                      * If the size requested by the host is smaller than
+                      * FullSize, the struct will be truncated */
+
+       /* Common parameters */
+       u32 IsRfLocked; /* 0 - not locked, 1 - locked */
+       u32 IsDemodLocked; /* 0 - not locked, 1 - locked */
+       u32 IsExternalLNAOn; /* 0 - external LNA off, 1 - external LNA on */
+
+       /* Reception quality */
+       s32  SNR; /* dB */
+       s32  RSSI; /* dBm */
+       s32  InBandPwr; /* In band power in dBM */
+       s32  CarrierOffset; /* Carrier Offset in Hz */
+
+       /* Transmission parameters */
+       u32 Frequency; /* Frequency in Hz */
+       u32 Bandwidth; /* Bandwidth in MHz */
+       u32 TransmissionMode; /* ISDB-T transmission mode */
+       u32 ModemState; /* 0 - Acquisition, 1 - Locked */
+       u32 GuardInterval; /* Guard Interval, 1 divided by value */
+       u32 SystemType; /* ISDB-T system type (ISDB-T / ISDB-Tsb) */
+       u32 PartialReception; /* TRUE - partial reception, FALSE otherwise */
+       u32 NumOfLayers; /* Number of ISDB-T layers in the network */
+
+       /* Per-layer information */
+       /* Layers A, B and C */
+       struct SMSHOSTLIB_ISDBT_LAYER_STAT_ST   LayerInfo[3];
+       /* Per-layer statistics, see SMSHOSTLIB_ISDBT_LAYER_STAT_ST */
+
+       /* Interface information */
+       u32 SmsToHostTxErrors; /* Total number of transmission errors. */
+};
+
 struct PID_STATISTICS_DATA_S {
        struct PID_BURST_S {
                u32 size;
diff -r ac3e520a01e1 -r 786efa7be8db linux/drivers/media/dvb/siano/smsdvb.c
--- a/linux/drivers/media/dvb/siano/smsdvb.c    Wed Dec 23 08:48:18 2009 +0100
+++ b/linux/drivers/media/dvb/siano/smsdvb.c    Sat Dec 26 12:42:17 2009 +0100
@@ -116,6 +116,118 @@
        }
 }
 
+
+static void smsdvb_update_dvb_stats(struct RECEPTION_STATISTICS_S 
*pReceptionData,
+                                  struct SMSHOSTLIB_STATISTICS_ST *p)
+{
+       if (sms_dbg & 2) {
+               printk(KERN_DEBUG "Reserved = %d", p->Reserved);
+               printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
+               printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
+               printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
+               printk(KERN_DEBUG "SNR = %d", p->SNR);
+               printk(KERN_DEBUG "BER = %d", p->BER);
+               printk(KERN_DEBUG "FIB_CRC = %d", p->FIB_CRC);
+               printk(KERN_DEBUG "TS_PER = %d", p->TS_PER);
+               printk(KERN_DEBUG "MFER = %d", p->MFER);
+               printk(KERN_DEBUG "RSSI = %d", p->RSSI);
+               printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
+               printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
+               printk(KERN_DEBUG "Frequency = %d", p->Frequency);
+               printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
+               printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
+               printk(KERN_DEBUG "ModemState = %d", p->ModemState);
+               printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
+               printk(KERN_DEBUG "CodeRate = %d", p->CodeRate);
+               printk(KERN_DEBUG "LPCodeRate = %d", p->LPCodeRate);
+               printk(KERN_DEBUG "Hierarchy = %d", p->Hierarchy);
+               printk(KERN_DEBUG "Constellation = %d", p->Constellation);
+               printk(KERN_DEBUG "BurstSize = %d", p->BurstSize);
+               printk(KERN_DEBUG "BurstDuration = %d", p->BurstDuration);
+               printk(KERN_DEBUG "BurstCycleTime = %d", p->BurstCycleTime);
+               printk(KERN_DEBUG "CalculatedBurstCycleTime = %d", 
p->CalculatedBurstCycleTime);
+               printk(KERN_DEBUG "NumOfRows = %d", p->NumOfRows);
+               printk(KERN_DEBUG "NumOfPaddCols = %d", p->NumOfPaddCols);
+               printk(KERN_DEBUG "NumOfPunctCols = %d", p->NumOfPunctCols);
+               printk(KERN_DEBUG "ErrorTSPackets = %d", p->ErrorTSPackets);
+               printk(KERN_DEBUG "TotalTSPackets = %d", p->TotalTSPackets);
+               printk(KERN_DEBUG "NumOfValidMpeTlbs = %d", 
p->NumOfValidMpeTlbs);
+               printk(KERN_DEBUG "NumOfInvalidMpeTlbs = %d", 
p->NumOfInvalidMpeTlbs);
+               printk(KERN_DEBUG "NumOfCorrectedMpeTlbs = %d", 
p->NumOfCorrectedMpeTlbs);
+               printk(KERN_DEBUG "BERErrorCount = %d", p->BERErrorCount);
+               printk(KERN_DEBUG "BERBitCount = %d", p->BERBitCount);
+               printk(KERN_DEBUG "SmsToHostTxErrors = %d", 
p->SmsToHostTxErrors);
+               printk(KERN_DEBUG "PreBER = %d", p->PreBER);
+               printk(KERN_DEBUG "CellId = %d", p->CellId);
+               printk(KERN_DEBUG "DvbhSrvIndHP = %d", p->DvbhSrvIndHP);
+               printk(KERN_DEBUG "DvbhSrvIndLP = %d", p->DvbhSrvIndLP);
+               printk(KERN_DEBUG "NumMPEReceived = %d", p->NumMPEReceived);
+       }
+
+       pReceptionData->IsDemodLocked = p->IsDemodLocked;
+
+       pReceptionData->SNR = p->SNR;
+       pReceptionData->BER = p->BER;
+       pReceptionData->BERErrorCount = p->BERErrorCount;
+       pReceptionData->InBandPwr = p->InBandPwr;
+       pReceptionData->ErrorTSPackets = p->ErrorTSPackets;
+};
+
+
+static void smsdvb_update_isdbt_stats(struct RECEPTION_STATISTICS_S 
*pReceptionData,
+                                   struct SMSHOSTLIB_STATISTICS_ISDBT_ST *p)
+{
+       int i;
+
+       if (sms_dbg & 2) {
+               printk(KERN_DEBUG "IsRfLocked = %d", p->IsRfLocked);
+               printk(KERN_DEBUG "IsDemodLocked = %d", p->IsDemodLocked);
+               printk(KERN_DEBUG "IsExternalLNAOn = %d", p->IsExternalLNAOn);
+               printk(KERN_DEBUG "SNR = %d", p->SNR);
+               printk(KERN_DEBUG "RSSI = %d", p->RSSI);
+               printk(KERN_DEBUG "InBandPwr = %d", p->InBandPwr);
+               printk(KERN_DEBUG "CarrierOffset = %d", p->CarrierOffset);
+               printk(KERN_DEBUG "Frequency = %d", p->Frequency);
+               printk(KERN_DEBUG "Bandwidth = %d", p->Bandwidth);
+               printk(KERN_DEBUG "TransmissionMode = %d", p->TransmissionMode);
+               printk(KERN_DEBUG "ModemState = %d", p->ModemState);
+               printk(KERN_DEBUG "GuardInterval = %d", p->GuardInterval);
+               printk(KERN_DEBUG "SystemType = %d", p->SystemType);
+               printk(KERN_DEBUG "PartialReception = %d", p->PartialReception);
+               printk(KERN_DEBUG "NumOfLayers = %d", p->NumOfLayers);
+               printk(KERN_DEBUG "SmsToHostTxErrors = %d", 
p->SmsToHostTxErrors);
+
+               for (i = 0; i < 3; i++) {
+                       printk(KERN_DEBUG "%d: CodeRate = %d", i, 
p->LayerInfo[i].CodeRate);
+                       printk(KERN_DEBUG "%d: Constellation = %d", i, 
p->LayerInfo[i].Constellation);
+                       printk(KERN_DEBUG "%d: BER = %d", i, 
p->LayerInfo[i].BER);
+                       printk(KERN_DEBUG "%d: BERErrorCount = %d", i, 
p->LayerInfo[i].BERErrorCount);
+                       printk(KERN_DEBUG "%d: BERBitCount = %d", i, 
p->LayerInfo[i].BERBitCount);
+                       printk(KERN_DEBUG "%d: PreBER = %d", i, 
p->LayerInfo[i].PreBER);
+                       printk(KERN_DEBUG "%d: TS_PER = %d", i, 
p->LayerInfo[i].TS_PER);
+                       printk(KERN_DEBUG "%d: ErrorTSPackets = %d", i, 
p->LayerInfo[i].ErrorTSPackets);
+                       printk(KERN_DEBUG "%d: TotalTSPackets = %d", i, 
p->LayerInfo[i].TotalTSPackets);
+                       printk(KERN_DEBUG "%d: TILdepthI = %d", i, 
p->LayerInfo[i].TILdepthI);
+                       printk(KERN_DEBUG "%d: NumberOfSegments = %d", i, 
p->LayerInfo[i].NumberOfSegments);
+                       printk(KERN_DEBUG "%d: TMCCErrors = %d", i, 
p->LayerInfo[i].TMCCErrors);
+               }
+       }
+
+       pReceptionData->IsDemodLocked = p->IsDemodLocked;
+
+       pReceptionData->SNR = p->SNR;
+       pReceptionData->InBandPwr = p->InBandPwr;
+
+       pReceptionData->ErrorTSPackets = 0;
+       pReceptionData->BER = 0;
+       pReceptionData->BERErrorCount = 0;
+       for (i = 0; i < 3; i++) {
+               pReceptionData->BER += p->LayerInfo[i].BER;
+               pReceptionData->BERErrorCount += p->LayerInfo[i].BERErrorCount;
+               pReceptionData->ErrorTSPackets += 
p->LayerInfo[i].ErrorTSPackets;
+       }
+}
+
 static int smsdvb_onresponse(void *context, struct smscore_buffer_t *cb)
 {
        struct smsdvb_client_t *client = (struct smsdvb_client_t *) context;
@@ -218,6 +330,40 @@
                is_status_update = true;
                break;
        }
+       case MSG_SMS_GET_STATISTICS_RES: {
+               union {
+                       struct SMSHOSTLIB_STATISTICS_ISDBT_ST  isdbt;
+                       struct SmsMsgStatisticsInfo_ST         dvb;
+               } *p = (void *) (phdr + 1);
+               struct RECEPTION_STATISTICS_S *pReceptionData =
+                               &client->sms_stat_dvb.ReceptionData;
+
+               sms_info("MSG_SMS_GET_STATISTICS_RES");
+
+               is_status_update = true;
+
+               switch (smscore_get_device_mode(client->coredev)) {
+               case DEVICE_MODE_ISDBT:
+               case DEVICE_MODE_ISDBT_BDA:
+                       smsdvb_update_isdbt_stats(pReceptionData, &p->isdbt);
+                       break;
+               default:
+                       smsdvb_update_dvb_stats(pReceptionData, &p->dvb.Stat);
+               }
+               if (!pReceptionData->IsDemodLocked) {
+                       pReceptionData->SNR = 0;
+                       pReceptionData->BER = 0;
+                       pReceptionData->BERErrorCount = 0;
+                       pReceptionData->InBandPwr = 0;
+                       pReceptionData->ErrorTSPackets = 0;
+               }
+
+               complete(&client->tune_done);
+               break;
+       }
+       default:
+               sms_info("Unhandled message %d", phdr->msgType);
+
        }
        smscore_putbuffer(client->coredev, cb);
 
@@ -234,10 +380,10 @@
                                                DVB3_EVENT_UNC_ERR);
 
                } else {
-                       /*client->fe_status =
-                               (phdr->msgType == MSG_SMS_NO_SIGNAL_IND) ?
-                               0 : FE_HAS_SIGNAL;*/
-                       client->fe_status = 0;
+                       if (client->sms_stat_dvb.ReceptionData.IsRfLocked)
+                               client->fe_status = FE_HAS_SIGNAL | 
FE_HAS_CARRIER;
+                       else
+                               client->fe_status = 0;
                        sms_board_dvb3_event(client, DVB3_EVENT_FE_UNLOCK);
                }
        }
@@ -326,6 +472,20 @@
                                                0 : -ETIME;
 }
 
+static int smsdvb_send_statistics_request(struct smsdvb_client_t *client)
+{
+       int rc;
+       struct SmsMsgHdr_ST Msg = { MSG_SMS_GET_STATISTICS_REQ,
+                                   DVBT_BDA_CONTROL_MSG_ID,
+                                   HIF_TASK,
+                                   sizeof(struct SmsMsgHdr_ST), 0 };
+
+       rc = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
+                                         &client->tune_done);
+
+       return rc;
+}
+
 static inline int led_feedback(struct smsdvb_client_t *client)
 {
        if (client->fe_status & FE_HAS_LOCK)
@@ -338,33 +498,43 @@
 
 static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
 {
+       int rc;
        struct smsdvb_client_t *client;
        client = container_of(fe, struct smsdvb_client_t, frontend);
 
+       rc = smsdvb_send_statistics_request(client);
+
        *stat = client->fe_status;
 
        led_feedback(client);
 
-       return 0;
+       return rc;
 }
 
 static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
 {
+       int rc;
        struct smsdvb_client_t *client;
        client = container_of(fe, struct smsdvb_client_t, frontend);
 
+       rc = smsdvb_send_statistics_request(client);
+
        *ber = client->sms_stat_dvb.ReceptionData.BER;
 
        led_feedback(client);
 
-       return 0;
+       return rc;
 }
 
 static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
 {
+       int rc;
+
        struct smsdvb_client_t *client;
        client = container_of(fe, struct smsdvb_client_t, frontend);
 
+       rc = smsdvb_send_statistics_request(client);
+
        if (client->sms_stat_dvb.ReceptionData.InBandPwr < -95)
                *strength = 0;
                else if (client->sms_stat_dvb.ReceptionData.InBandPwr > -29)
@@ -376,31 +546,37 @@
 
        led_feedback(client);
 
-       return 0;
+       return rc;
 }
 
 static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
 {
+       int rc;
        struct smsdvb_client_t *client;
        client = container_of(fe, struct smsdvb_client_t, frontend);
 
+       rc = smsdvb_send_statistics_request(client);
+
        *snr = client->sms_stat_dvb.ReceptionData.SNR;
 
        led_feedback(client);
 
-       return 0;
+       return rc;
 }
 
 static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
 {
+       int rc;
        struct smsdvb_client_t *client;
        client = container_of(fe, struct smsdvb_client_t, frontend);
 
+       rc = smsdvb_send_statistics_request(client);
+
        *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets;
 
        led_feedback(client);
 
-       return 0;
+       return rc;
 }
 
 static int smsdvb_get_tune_settings(struct dvb_frontend *fe,
@@ -415,8 +591,9 @@
 }
 
 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 =
                container_of(fe, struct smsdvb_client_t, frontend);
 
@@ -430,27 +607,38 @@
        client->fe_status = FE_HAS_SIGNAL;
        client->event_fe_state = -1;
        client->event_unc_state = -1;
+       fe->dtv_property_cache.delivery_system = SYS_DVBT;
 
        Msg.Msg.msgSrcId = DVBT_BDA_CONTROL_MSG_ID;
        Msg.Msg.msgDstId = HIF_TASK;
        Msg.Msg.msgFlags = 0;
        Msg.Msg.msgType = MSG_SMS_RF_TUNE_REQ;
        Msg.Msg.msgLength = sizeof(Msg);
-       Msg.Data[0] = fep->frequency;
+       Msg.Data[0] = c->frequency;
        Msg.Data[2] = 12000000;
 
-       sms_debug("freq %d band %d",
-                 fep->frequency, fep->u.ofdm.bandwidth);
+       sms_info("%s: freq %d band %d", __func__, c->frequency,
+                c->bandwidth_hz);
 
-       switch (fep->u.ofdm.bandwidth) {
-       case BANDWIDTH_8_MHZ: Msg.Data[1] = BW_8_MHZ; break;
-       case BANDWIDTH_7_MHZ: Msg.Data[1] = BW_7_MHZ; break;
-       case BANDWIDTH_6_MHZ: Msg.Data[1] = BW_6_MHZ; break;
+       switch (c->bandwidth_hz / 1000000) {
+       case 8:
+               Msg.Data[1] = BW_8_MHZ;
+               break;
+       case 7:
+               Msg.Data[1] = BW_7_MHZ;
+               break;
+       case 6:
+               Msg.Data[1] = BW_6_MHZ;
+               break;
 #if 0
-       case BANDWIDTH_5_MHZ: Msg.Data[1] = BW_5_MHZ; break;
+       case 5:
+               Msg.Data[1] = BW_5_MHZ;
+               break;
 #endif
-       case BANDWIDTH_AUTO: return -EOPNOTSUPP;
-       default: return -EINVAL;
+       case 0:
+               return -EOPNOTSUPP;
+       default:
+               return -EINVAL;
        }
        /* Disable LNA, if any. An error is returned if no LNA is present */
        ret = sms_board_lna_control(client->coredev, 0);
@@ -475,9 +663,9 @@
 }
 
 static int smsdvb_isdbt_set_frontend(struct dvb_frontend *fe,
-                                    struct dvb_frontend_parameters *fep,
-                                    u32 SegmentNumber)
+                                    struct dvb_frontend_parameters *p)
 {
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct smsdvb_client_t *client =
                container_of(fe, struct smsdvb_client_t, frontend);
 
@@ -486,39 +674,55 @@
                u32             Data[4];
        } Msg;
 
+       fe->dtv_property_cache.delivery_system = SYS_ISDBT;
+
        Msg.Msg.msgSrcId  = DVBT_BDA_CONTROL_MSG_ID;
        Msg.Msg.msgDstId  = HIF_TASK;
        Msg.Msg.msgFlags  = 0;
        Msg.Msg.msgType   = MSG_SMS_ISDBT_TUNE_REQ;
        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",
-                 fep->frequency, fep->u.ofdm.bandwidth, SegmentNumber);
+       if (c->isdbt_sb_segment_idx == -1)
+               c->isdbt_sb_segment_idx = 0;
 
-       switch (fep->u.ofdm.bandwidth) {
-       case BANDWIDTH_8_MHZ:
+       switch (c->isdbt_sb_segment_count) {
+       case 3:
                Msg.Data[1] = BW_ISDBT_3SEG;
                break;
-       case BANDWIDTH_7_MHZ:
-               Msg.Data[1] = BW_ISDBT_3SEG;
-               break;
-       case BANDWIDTH_6_MHZ:
+       case 1:
                Msg.Data[1] = BW_ISDBT_1SEG;
                break;
-#if 0
-       case BANDWIDTH_5_MHZ:
-               Msg.Data[1] = BW_ISDBT_1SEG;
+       case 0: /* AUTO */
+               switch (c->bandwidth_hz / 1000000) {
+               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;
-#endif
-       case BANDWIDTH_AUTO:
-               return -EOPNOTSUPP;
        default:
+               sms_info("Segment count %d not supported", 
c->isdbt_sb_segment_count);
                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),
                                           &client->tune_done);
 }
@@ -536,13 +740,7 @@
                return smsdvb_dvbt_set_frontend(fe, fep);
        case DEVICE_MODE_ISDBT:
        case DEVICE_MODE_ISDBT_BDA:
-       {
-               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);
-       }
+               return smsdvb_isdbt_set_frontend(fe, fep);
        default:
                return -EINVAL;
        }


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/786efa7be8dbeac9d7197630594b7b5651c1ca91

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to