diff -Nru dvb-apps/util/scan/dump-zap.c dvb-apps-S2/util/scan/dump-zap.c --- dvb-apps/util/scan/dump-zap.c 2008-02-24 17:32:37.000000000 +0100 +++ dvb-apps-S2/util/scan/dump-zap.c 2008-02-24 17:00:45.000000000 +0100 @@ -1,5 +1,6 @@ #include #include +#include #include "dump-zap.h" static const char *inv_name [] = { @@ -66,7 +67,23 @@ "HIERARCHY_AUTO" }; - +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 +void zap_dump_dvb_parameters (FILE *f, fe_type_t type, struct dvbfe_params *p, char polarity, int sat_number) +{ + switch (type) { + case FE_QPSK: + fprintf (f, "%i:", p->frequency / 1000); /* channels.conf wants MHz */ + fprintf (f, "%c:", polarity); + fprintf (f, "%d:", sat_number); + fprintf (f, "%i", p->delsys.dvbs2.symbol_rate / 1000); /* channels.conf wants kBaud */ + /*fprintf (f, "%s", fec_name[p->u.qpsk.fec_inner]);*/ + break; + + default: + ; + }; +} +#else void zap_dump_dvb_parameters (FILE *f, fe_type_t type, struct dvb_frontend_parameters *p, char polarity, int sat_number) { switch (type) { @@ -107,19 +124,41 @@ ; }; } +#endif +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 void zap_dump_service_parameter_set (FILE *f, const char *service_name, fe_type_t type, - struct dvb_frontend_parameters *p, + struct dvbfe_params *p, char polarity, int sat_number, uint16_t video_pid, uint16_t *audio_pid, - uint16_t service_id) + uint16_t service_id, + unsigned int modulation_system) { fprintf (f, "%s:", service_name); zap_dump_dvb_parameters (f, type, p, polarity, sat_number); fprintf (f, ":%i:%i:%i", video_pid, audio_pid[0], service_id); + fprintf (f, ":%i", modulation_system); fprintf (f, "\n"); } +#else +void zap_dump_service_parameter_set (FILE *f, + const char *service_name, + fe_type_t type, + struct dvb_frontend_parameters *p, + char polarity, + int sat_number, + uint16_t video_pid, + uint16_t *audio_pid, + uint16_t service_id, + unsigned int modulation_system) +{ + fprintf (f, "%s:", service_name); + zap_dump_dvb_parameters (f, type, p, polarity, sat_number); + fprintf (f, ":%i:%i:%i", video_pid, audio_pid[0], service_id); + fprintf (f, "\n"); +} +#endif diff -Nru dvb-apps/util/scan/dump-zap.h dvb-apps-S2/util/scan/dump-zap.h --- dvb-apps/util/scan/dump-zap.h 2008-02-24 17:32:37.000000000 +0100 +++ dvb-apps-S2/util/scan/dump-zap.h 2008-02-24 17:02:22.000000000 +0100 @@ -3,10 +3,27 @@ #include #include +#include +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 +extern void zap_dump_dvb_parameters (FILE *f, fe_type_t type, + struct dvbfe_params *p, char polarity, int sat_number); +#else extern void zap_dump_dvb_parameters (FILE *f, fe_type_t type, struct dvb_frontend_parameters *t, char polarity, int sat); +#endif +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 +extern void zap_dump_service_parameter_set (FILE *f, + const char *service_name, + fe_type_t type, + struct dvbfe_params *t, + char polarity, int sat, + uint16_t video_pid, + uint16_t *audio_pid, + uint16_t service_id, + unsigned int modulation_system); +#else extern void zap_dump_service_parameter_set (FILE *f, const char *service_name, fe_type_t type, @@ -14,6 +31,8 @@ char polarity, int sat, uint16_t video_pid, uint16_t *audio_pid, - uint16_t service_id); + uint16_t service_id, + unsigned int modulation_system); +#endif #endif diff -Nru dvb-apps/util/scan/Makefile dvb-apps-S2/util/scan/Makefile --- dvb-apps/util/scan/Makefile 2008-02-24 17:32:37.000000000 +0100 +++ dvb-apps-S2/util/scan/Makefile 2008-02-24 17:03:31.000000000 +0100 @@ -14,7 +14,7 @@ removing = atsc_psip_section.c atsc_psip_section.h -CPPFLAGS += -DDATADIR=\"$(prefix)/share\" +CPPFLAGS += -I/usr/include -DDATADIR=\"$(prefix)/share\" .PHONY: all diff -Nru dvb-apps/util/scan/scan.c dvb-apps-S2/util/scan/scan.c --- dvb-apps/util/scan/scan.c 2008-02-24 17:32:40.000000000 +0100 +++ dvb-apps-S2/util/scan/scan.c 2008-02-24 17:31:54.000000000 +0100 @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -133,9 +134,13 @@ int original_network_id; int transport_stream_id; enum fe_type type; +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + struct dvbfe_params fe_params; +#else struct dvb_frontend_parameters param; enum polarisation polarisation; /* only for DVB-S */ int orbital_pos; /* only for DVB-S */ + unsigned int modulation_system : 1; /* DVB-S/S2-modulation 0 = DVB-S, 1 = DVB-S2 */ unsigned int we_flag : 1; /* West/East Flag - only for DVB-S */ unsigned int scan_done : 1; unsigned int last_tuning_failed : 1; @@ -193,7 +198,11 @@ { struct transponder *tp = calloc(1, sizeof(*tp)); +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + tp->fe_params.frequency = frequency; +#else tp->param.frequency = frequency; +#endif INIT_LIST_HEAD(&tp->list); INIT_LIST_HEAD(&tp->services); list_add_tail(&tp->list, &new_transponders); @@ -223,13 +232,23 @@ tp = list_entry(pos, struct transponder, list); if (current_tp_only) return tp; +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + if (is_same_transponder(tp->fe_params.frequency, frequency)) + return tp; +#else if (is_same_transponder(tp->param.frequency, frequency)) return tp; +#endif } list_for_each(pos, &new_transponders) { tp = list_entry(pos, struct transponder, list); +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + if (is_same_transponder(tp->fe_params.frequency, frequency)) + return tp; +#else if (is_same_transponder(tp->param.frequency, frequency)) return tp; +#endif } return NULL; } @@ -240,10 +259,15 @@ d->original_network_id = s->original_network_id; d->transport_stream_id = s->transport_stream_id; d->type = s->type; +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + memcpy(&d->fe_params, &s->fe_params, sizeof(d->fe_params)); +#else memcpy(&d->param, &s->param, sizeof(d->param)); +#endif d->polarisation = s->polarisation; d->orbital_pos = s->orbital_pos; d->we_flag = s->we_flag; + d->modulation_system = s->modulation_system; d->scan_done = s->scan_done; d->last_tuning_failed = s->last_tuning_failed; d->other_frequency_flag = s->other_frequency_flag; @@ -389,6 +413,7 @@ static void parse_cable_delivery_system_descriptor (const unsigned char *buf, struct transponder *t) { +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR<3 if (!t) { warning("cable_delivery_system_descriptor outside transport stream definition (ignored)\n"); return; @@ -417,6 +442,18 @@ dprintf(5, " (tuning failed)"); dprintf(5, "\n"); } +#endif +} + +static void parse_s2_satellite_delivery_system_descriptor (const unsigned char *buf, + struct transponder *t) +{ + if (!t) { + warning("satellite_delivery_system_descriptor outside transport stream definition (ignored)\n"); + return; + } + t->type = FE_QPSK; + t->modulation_system = 1; } static void parse_satellite_delivery_system_descriptor (const unsigned char *buf, @@ -427,6 +464,30 @@ return; } t->type = FE_QPSK; + t->modulation_system = buf[8] >> 1 & 0x01; +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + t->fe_params.frequency = 10 * bcd32_to_cpu (buf[2], buf[3], buf[4], buf[5]); + if(t->fe_params.frequency == 11914500) + t->modulation_system = 1; + + switch(t->modulation_system) { + case 0: + t->fe_params.delsys.dvbs.fec = fec_tab[buf[12] & 0x07]; + t->fe_params.delsys.dvbs.symbol_rate = 10 * bcd32_to_cpu (buf[9], + buf[10], + buf[11], + buf[12] & 0xf0); + break; + case 1: + t->fe_params.delsys.dvbs2.fec = fec_tab[buf[12] & 0x07]; + t->fe_params.delsys.dvbs2.symbol_rate = 10 * bcd32_to_cpu (buf[9], + buf[10], + buf[11], + buf[12] & 0xf0); + break; + } + t->fe_params.inversion = INVERSION_AUTO; +#else t->param.frequency = 10 * bcd32_to_cpu (buf[2], buf[3], buf[4], buf[5]); t->param.u.qpsk.fec_inner = fec_tab[buf[12] & 0x07]; t->param.u.qpsk.symbol_rate = 10 * bcd32_to_cpu (buf[9], @@ -434,6 +495,8 @@ buf[11], buf[12] & 0xf0); + t->param.inversion = spectral_inversion; +#endif t->polarisation = (buf[8] >> 5) & 0x03; t->param.inversion = spectral_inversion; @@ -455,6 +518,7 @@ static void parse_terrestrial_delivery_system_descriptor (const unsigned char *buf, struct transponder *t) { +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR<3 static const fe_modulation_t m_tab [] = { QPSK, QAM_16, QAM_64, QAM_AUTO }; static const fe_code_rate_t ofec_tab [8] = { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8 }; @@ -503,6 +567,7 @@ dprintf(5, " (tuning failed)"); dprintf(5, "\n"); } +#endif } static void parse_frequency_list_descriptor (const unsigned char *buf, @@ -654,10 +719,18 @@ parse_satellite_delivery_system_descriptor (buf, data); break; + case 0x79: + info("ERROR: S2_satellite_delivery_system_descriptor not parsed\n"); + if( t == NIT) + parse_s2_satellite_delivery_system_descriptor (buf, data); + break; + +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 case 0x44: if (t == NIT) parse_cable_delivery_system_descriptor (buf, data); break; +#endif case 0x48: if (t == SDT) @@ -669,10 +742,12 @@ parse_ca_identifier_descriptor (buf, data); break; +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 case 0x5a: if (t == NIT) parse_terrestrial_delivery_system_descriptor (buf, data); break; +#endif case 0x62: if (t == NIT) @@ -878,9 +953,15 @@ if (tn.type == fe_info.type) { /* only add if develivery_descriptor matches FE type */ +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + t = find_transponder(tn.fe_params.frequency); + if (!t) + t = alloc_transponder(tn.fe_params.frequency); +#else t = find_transponder(tn.param.frequency); if (!t) t = alloc_transponder(tn.param.frequency); +#endif copy_transponder(t, &tn); } @@ -1454,12 +1535,21 @@ static int __tune_to_transponder (int frontend_fd, struct transponder *t) { +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + struct dvbfe_params fe_params; +#else struct dvb_frontend_parameters p; fe_status_t s; int i; current_tp = t; +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + if (mem_is_zero (&t->fe_params, sizeof(struct dvbfe_params))) + return -1; + + memcpy (&fe_params, &t->fe_params, sizeof(struct dvbfe_params)); +#else if (mem_is_zero (&t->param, sizeof(struct dvb_frontend_parameters))) return -1; @@ -1472,7 +1562,47 @@ dprintf(1, " (tuning failed)"); dprintf(1, "\n"); } +#endif + +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + if (t->type == FE_QPSK) { + dprintf(1,"Tune to frequency %d\n",fe_params.frequency); + if (lnb_type.high_val) { + if (lnb_type.switch_val) { + /* Voltage-controlled switch */ + int hiband = 0; + + if (fe_params.frequency >= lnb_type.switch_val) + hiband = 1; + + setup_switch (frontend_fd, + switch_pos, + t->polarisation == POLARISATION_VERTICAL ? 0 : 1, + hiband); + usleep(50000); + if (hiband) + fe_params.frequency = abs(fe_params.frequency - lnb_type.high_val); + else + fe_params.frequency = abs(fe_params.frequency - lnb_type.low_val); + } else { + /* C-Band Multipoint LNBf */ + fe_params.frequency = abs(fe_params.frequency - + (t->polarisation == POLARISATION_VERTICAL ? + lnb_type.low_val: lnb_type.high_val)); + } + } else { + /* Monopoint LNBf without switch */ + fe_params.frequency = abs(fe_params.frequency - lnb_type.low_val); + } + if (verbosity >= 2) + dprintf(1,"DVB-S IF freq is %d\n",fe_params.frequency); + } + if (ioctl(frontend_fd, DVBFE_SET_PARAMS, &fe_params) != 0) { + errorn("Setting frontend parameters failed"); + return -1; + } +#else if (t->type == FE_QPSK) { if (lnb_type.high_val) { if (lnb_type.switch_val) { @@ -1508,8 +1638,9 @@ errorn("Setting frontend parameters failed"); return -1; } +#endif - for (i = 0; i < 10; i++) { + for (i = 0; i < 100; i++) { usleep (200000); if (ioctl(frontend_fd, FE_READ_STATUS, &s) == -1) { @@ -1547,6 +1678,38 @@ return -1; } + struct dvbfe_info fe_info1; + + // a temporary hack, need to clean + memset(&fe_info1, 0, sizeof (struct dvbfe_info)); + + if(t->modulation_system == 0) + fe_info1.delivery = DVBFE_DELSYS_DVBS; + else if(t->modulation_system == 1) + fe_info1.delivery = DVBFE_DELSYS_DVBS2; + + int result = ioctl(frontend_fd, DVBFE_GET_INFO, &fe_info1); + if (result < 0) { + perror("ioctl DVBFE_GET_INFO failed"); + t->last_tuning_failed = 1; + return -1; + } + + switch (fe_info1.delivery) { + case DVBFE_DELSYS_DVBS: + info("----------------------------------> Using '%s' DVB-S\n", fe_info.name); + break; + case DVBFE_DELSYS_DSS: + info("----------------------------------> Using '%s' DSS\n", fe_info.name); + break; + case DVBFE_DELSYS_DVBS2: + info("----------------------------------> Using '%s' DVB-S2\n", fe_info.name); + break; + default: + info("Unsupported Delivery system (%d)!\n", fe_info1.delivery); + t->last_tuning_failed = 1; + return -1; + } if (__tune_to_transponder (frontend_fd, t) == 0) return 0; @@ -1575,15 +1738,24 @@ /* remember tuning to the old frequency failed */ to = calloc(1, sizeof(*to)); +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + to->fe_params.frequency = t->fe_params.frequency; +#else to->param.frequency = t->param.frequency; +#endif to->wrong_frequency = 1; INIT_LIST_HEAD(&to->list); INIT_LIST_HEAD(&to->services); list_add_tail(&to->list, &scanned_transponders); copy_transponder(to, t); +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + t->fe_params.frequency = freq; + info("retrying with f=%d\n", t->fe_params.frequency); +#else t->param.frequency = freq; info("retrying with f=%d\n", t->param.frequency); +#endif goto retry; } } @@ -1741,6 +1913,15 @@ t->polarisation = POLARISATION_VERTICAL;; break; } +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + t->fe_params.inversion = spectral_inversion; + t->fe_params.delsys.dvbs2.symbol_rate = sr; + t->fe_params.delsys.dvbs2.fec = str2fec(fec); + info("initial transponder %u %c %u %d\n", + t->fe_params.frequency, + pol[0], sr, + t->fe_params.delsys.dvbs2.symbol_rate); +#else t->param.inversion = spectral_inversion; t->param.u.qpsk.symbol_rate = sr; t->param.u.qpsk.fec_inner = str2fec(fec); @@ -1748,7 +1929,9 @@ t->param.frequency, pol[0], sr, t->param.u.qpsk.fec_inner); +#endif } +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR<3 else if (sscanf(buf, "C %u %u %4s %6s\n", &f, &sr, fec, qam) == 4) { t = alloc_transponder(f); t->type = FE_QAM; @@ -1793,7 +1976,9 @@ t = alloc_transponder(f); t->type = FE_ATSC; t->param.u.vsb.modulation = str2qam(qam); - } else + } +#endif + else error("cannot parse'%s'\n", buf); } @@ -1996,7 +2181,7 @@ continue; /* FTA only */ switch (output_format) { - case OUTPUT_PIDS: + /*case OUTPUT_PIDS: pids_dump_service_parameter_set (stdout, s); break; case OUTPUT_VDR: @@ -2025,17 +2210,24 @@ vdr_version, vdr_dump_channum, s->channel_num); - break; + break;*/ case OUTPUT_ZAP: + if(s->audio_pid[0] == 0 && s->ac3_pid != 0) + s->audio_pid[0] = s->ac3_pid; zap_dump_service_parameter_set (stdout, s->service_name, t->type, +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + &t->fe_params, +#else &t->param, +#endif sat_polarisation(t), sat_number(t), s->video_pid, s->audio_pid, - s->service_id); + s->service_id, + t->modulation_system); default: break; } @@ -2304,13 +2496,18 @@ static void dump_dvb_parameters (FILE *f, struct transponder *t) { switch (output_format) { - case OUTPUT_PIDS: + /*case OUTPUT_PIDS: case OUTPUT_VDR: vdr_dump_dvb_parameters(f, t->type, &t->param, sat_polarisation (t), t->orbital_pos, t->we_flag); break; - case OUTPUT_ZAP: - zap_dump_dvb_parameters (f, t->type, &t->param, + case OUTPUT_ZAP:*/ + zap_dump_dvb_parameters (f, t->type, +#if DVB_API_VERSION==3 && DVB_API_VERSION_MINOR>=3 + &t->fe_params, +#else + &t->param, +#endif sat_polarisation (t), sat_number (t)); break; default: