--- /dev/null
+/*
+ * File auto-generated from the kernel sources. Please, don't edit it
+ */
+#ifndef _DVB_V5_CONSTS_H
+#define _DVB_V5_CONSTS_H
+#include "dvb_frontend.h"
+struct fe_caps_name {
+ unsigned idx;
+ char *name;
+} fe_caps_name[30] = {
+ { FE_CAN_2G_MODULATION, "CAN_2G_MODULATION" },
+ { FE_CAN_8VSB, "CAN_8VSB" },
+ { FE_CAN_16VSB, "CAN_16VSB" },
+ { FE_CAN_BANDWIDTH_AUTO, "CAN_BANDWIDTH_AUTO" },
+ { FE_CAN_FEC_1_2, "CAN_FEC_1_2" },
+ { FE_CAN_FEC_2_3, "CAN_FEC_2_3" },
+ { FE_CAN_FEC_3_4, "CAN_FEC_3_4" },
+ { FE_CAN_FEC_4_5, "CAN_FEC_4_5" },
+ { FE_CAN_FEC_5_6, "CAN_FEC_5_6" },
+ { FE_CAN_FEC_6_7, "CAN_FEC_6_7" },
+ { FE_CAN_FEC_7_8, "CAN_FEC_7_8" },
+ { FE_CAN_FEC_8_9, "CAN_FEC_8_9" },
+ { FE_CAN_FEC_AUTO, "CAN_FEC_AUTO" },
+ { FE_CAN_GUARD_INTERVAL_AUTO, "CAN_GUARD_INTERVAL_AUTO" },
+ { FE_CAN_HIERARCHY_AUTO, "CAN_HIERARCHY_AUTO" },
+ { FE_CAN_INVERSION_AUTO, "CAN_INVERSION_AUTO" },
+ { FE_CAN_MUTE_TS, "CAN_MUTE_TS" },
+ { FE_CAN_QAM_16, "CAN_QAM_16" },
+ { FE_CAN_QAM_32, "CAN_QAM_32" },
+ { FE_CAN_QAM_64, "CAN_QAM_64" },
+ { FE_CAN_QAM_128, "CAN_QAM_128" },
+ { FE_CAN_QAM_256, "CAN_QAM_256" },
+ { FE_CAN_QAM_AUTO, "CAN_QAM_AUTO" },
+ { FE_CAN_QPSK, "CAN_QPSK" },
+ { FE_CAN_RECOVER, "CAN_RECOVER" },
+ { FE_CAN_TRANSMISSION_MODE_AUTO, "CAN_TRANSMISSION_MODE_AUTO" },
+ { FE_CAN_TURBO_FEC, "CAN_TURBO_FEC" },
+ { FE_HAS_EXTENDED_CAPS, "HAS_EXTENDED_CAPS" },
+ { FE_IS_STUPID, "IS_STUPID" },
+ { FE_NEEDS_BENDING, "NEEDS_BENDING" },
+};
+
+struct fe_status_name {
+ unsigned idx;
+ char *name;
+} fe_status_name[7] = {
+ { FE_HAS_CARRIER, "CARRIER" },
+ { FE_HAS_LOCK, "LOCK" },
+ { FE_HAS_SIGNAL, "SIGNAL" },
+ { FE_HAS_SYNC, "SYNC" },
+ { FE_HAS_VITERBI, "VITERBI" },
+ { FE_REINIT, "REINIT" },
+ { FE_TIMEDOUT, "TIMEDOUT" },
+};
+
+const char *fe_code_rate_name[12] = {
+ [FEC_1_2] = "1/2",
+ [FEC_2_3] = "2/3",
+ [FEC_3_4] = "3/4",
+ [FEC_3_5] = "3/5",
+ [FEC_4_5] = "4/5",
+ [FEC_5_6] = "5/6",
+ [FEC_6_7] = "6/7",
+ [FEC_7_8] = "7/8",
+ [FEC_8_9] = "8/9",
+ [FEC_9_10] = "9/10",
+ [FEC_AUTO] = "AUTO",
+ [FEC_NONE] = "NONE",
+};
+
+const char *fe_modulation_name[13] = {
+ [APSK_16] = "APSK/16",
+ [APSK_32] = "APSK/32",
+ [DQPSK] = "DQPSK",
+ [PSK_8] = "PSK/8",
+ [QAM_16] = "QAM/16",
+ [QAM_32] = "QAM/32",
+ [QAM_64] = "QAM/64",
+ [QAM_128] = "QAM/128",
+ [QAM_256] = "QAM/256",
+ [QAM_AUTO] = "QAM/AUTO",
+ [QPSK] = "QPSK",
+ [VSB_8] = "VSB/8",
+ [VSB_16] = "VSB/16",
+};
+
+const char *fe_transmission_mode_name[7] = {
+ [TRANSMISSION_MODE_1K] = "1K",
+ [TRANSMISSION_MODE_2K] = "2K",
+ [TRANSMISSION_MODE_4K] = "4K",
+ [TRANSMISSION_MODE_8K] = "8K",
+ [TRANSMISSION_MODE_16K] = "16K",
+ [TRANSMISSION_MODE_32K] = "32K",
+ [TRANSMISSION_MODE_AUTO] = "AUTO",
+};
+
+const unsigned fe_bandwidth_name[7] = {
+ [BANDWIDTH_1_712_MHZ] = 1712000,
+ [BANDWIDTH_5_MHZ] = 5000000,
+ [BANDWIDTH_6_MHZ] = 6000000,
+ [BANDWIDTH_7_MHZ] = 7000000,
+ [BANDWIDTH_8_MHZ] = 8000000,
+ [BANDWIDTH_10_MHZ] = 10000000,
+ [BANDWIDTH_AUTO] = 0,
+};
+
+const char *fe_guard_interval_name[8] = {
+ [GUARD_INTERVAL_1_4] = "1/4",
+ [GUARD_INTERVAL_1_8] = "1/8",
+ [GUARD_INTERVAL_1_16] = "1/16",
+ [GUARD_INTERVAL_1_32] = "1/32",
+ [GUARD_INTERVAL_1_128] = "1/128",
+ [GUARD_INTERVAL_19_128] = "19/128",
+ [GUARD_INTERVAL_19_256] = "19/256",
+ [GUARD_INTERVAL_AUTO] = "AUTO",
+};
+
+const char *fe_hierarchy_name[5] = {
+ [HIERARCHY_1] = "1",
+ [HIERARCHY_2] = "2",
+ [HIERARCHY_4] = "4",
+ [HIERARCHY_AUTO] = "AUTO",
+ [HIERARCHY_NONE] = "NONE",
+};
+
+const char *dvb_v5_name[44] = {
+ [DTV_API_VERSION] = "API_VERSION",
+ [DTV_BANDWIDTH_HZ] = "BANDWIDTH_HZ",
+ [DTV_CLEAR] = "CLEAR",
+ [DTV_CODE_RATE_HP] = "CODE_RATE_HP",
+ [DTV_CODE_RATE_LP] = "CODE_RATE_LP",
+ [DTV_DELIVERY_SYSTEM] = "DELIVERY_SYSTEM",
+ [DTV_DISEQC_MASTER] = "DISEQC_MASTER",
+ [DTV_DISEQC_SLAVE_REPLY] = "DISEQC_SLAVE_REPLY",
+ [DTV_DVBT2_PLP_ID] = "DVBT2_PLP_ID",
+ [DTV_FE_CAPABILITY] = "FE_CAPABILITY",
+ [DTV_FE_CAPABILITY_COUNT] = "FE_CAPABILITY_COUNT",
+ [DTV_FREQUENCY] = "FREQUENCY",
+ [DTV_GUARD_INTERVAL] = "GUARD_INTERVAL",
+ [DTV_HIERARCHY] = "HIERARCHY",
+ [DTV_INNER_FEC] = "INNER_FEC",
+ [DTV_INVERSION] = "INVERSION",
+ [DTV_ISDBS_TS_ID] = "ISDBS_TS_ID",
+ [DTV_ISDBT_LAYERA_FEC] = "ISDBT_LAYERA_FEC",
+ [DTV_ISDBT_LAYERA_MODULATION] = "ISDBT_LAYERA_MODULATION",
+ [DTV_ISDBT_LAYERA_SEGMENT_COUNT] = "ISDBT_LAYERA_SEGMENT_COUNT",
+ [DTV_ISDBT_LAYERA_TIME_INTERLEAVING] = "ISDBT_LAYERA_TIME_INTERLEAVING",
+ [DTV_ISDBT_LAYERB_FEC] = "ISDBT_LAYERB_FEC",
+ [DTV_ISDBT_LAYERB_MODULATION] = "ISDBT_LAYERB_MODULATION",
+ [DTV_ISDBT_LAYERB_SEGMENT_COUNT] = "ISDBT_LAYERB_SEGMENT_COUNT",
+ [DTV_ISDBT_LAYERB_TIME_INTERLEAVING] = "ISDBT_LAYERB_TIME_INTERLEAVING",
+ [DTV_ISDBT_LAYERC_FEC] = "ISDBT_LAYERC_FEC",
+ [DTV_ISDBT_LAYERC_MODULATION] = "ISDBT_LAYERC_MODULATION",
+ [DTV_ISDBT_LAYERC_SEGMENT_COUNT] = "ISDBT_LAYERC_SEGMENT_COUNT",
+ [DTV_ISDBT_LAYERC_TIME_INTERLEAVING] = "ISDBT_LAYERC_TIME_INTERLEAVING",
+ [DTV_ISDBT_LAYER_ENABLED] = "ISDBT_LAYER_ENABLED",
+ [DTV_ISDBT_PARTIAL_RECEPTION] = "ISDBT_PARTIAL_RECEPTION",
+ [DTV_ISDBT_SB_SEGMENT_COUNT] = "ISDBT_SB_SEGMENT_COUNT",
+ [DTV_ISDBT_SB_SEGMENT_IDX] = "ISDBT_SB_SEGMENT_IDX",
+ [DTV_ISDBT_SB_SUBCHANNEL_ID] = "ISDBT_SB_SUBCHANNEL_ID",
+ [DTV_ISDBT_SOUND_BROADCASTING] = "ISDBT_SOUND_BROADCASTING",
+ [DTV_MODULATION] = "MODULATION",
+ [DTV_PILOT] = "PILOT",
+ [DTV_ROLLOFF] = "ROLLOFF",
+ [DTV_SYMBOL_RATE] = "SYMBOL_RATE",
+ [DTV_TONE] = "TONE",
+ [DTV_TRANSMISSION_MODE] = "TRANSMISSION_MODE",
+ [DTV_TUNE] = "TUNE",
+ [DTV_UNDEFINED] = "UNDEFINED",
+ [DTV_VOLTAGE] = "VOLTAGE",
+};
+
+const char *delivery_system_name[18] = {
+ [SYS_ATSC] = "ATSC",
+ [SYS_ATSCMH] = "ATSCMH",
+ [SYS_CMMB] = "CMMB",
+ [SYS_DAB] = "DAB",
+ [SYS_DMBTH] = "DMBTH",
+ [SYS_DSS] = "DSS",
+ [SYS_DVBC_ANNEX_AC] = "DVBC/ANNEX_AC",
+ [SYS_DVBC_ANNEX_B] = "DVBC/ANNEX_B",
+ [SYS_DVBH] = "DVBH",
+ [SYS_DVBS] = "DVBS",
+ [SYS_DVBS2] = "DVBS2",
+ [SYS_DVBT] = "DVBT",
+ [SYS_DVBT2] = "DVBT2",
+ [SYS_ISDBC] = "ISDBC",
+ [SYS_ISDBS] = "ISDBS",
+ [SYS_ISDBT] = "ISDBT",
+ [SYS_TURBO] = "TURBO",
+ [SYS_UNDEFINED] = "UNDEFINED",
+};
+
+#endif
--- /dev/null
+#!/usr/bin/perl
+use strict;
+use File::Copy;
+
+use constant {
+ NORMAL => 0,
+ FE_CAPS => 1,
+ FE_STATUS => 2,
+ FE_CODERATE => 3,
+ FE_MODULATION => 4,
+ FE_TMODE => 5,
+ FE_BW => 6,
+ FE_GINTERVAL => 7,
+ FE_HIERARCHY => 8,
+ FE_DTS =>9,
+};
+
+my $dir = shift or die "Please specify the kernel include directory.";
+
+#
+# Put it into a canonical form
+#
+$dir =~ s,/$,,;
+$dir =~ s,/dvb$,,;
+$dir =~ s,/linux$,,;
+
+my %fe_caps;
+my %fe_status;
+my %fe_code_rate;
+my %fe_modulation;
+my %fe_t_mode;
+my %fe_bw;
+my %fe_guard_interval;
+my %fe_hierarchy;
+my %dvb_v5;
+my %fe_delivery_system;
+
+sub gen_fe($)
+{
+ my $file = shift;
+
+ my $mode = 0;
+
+ open IN, "<$file" or die "Can't open $file";
+
+ while (<IN>) {
+ #
+ # Mode FE_CAPS
+ #
+ if (m/typedef enum fe_caps\ {/) {
+ $mode = FE_CAPS;
+ next;
+ }
+ if ($mode == FE_CAPS) {
+ if (m/\} fe_caps_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(FE_)([^\s,=]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+
+ $fe_caps{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_STATUS
+ #
+ if (m/typedef enum fe_status\ {/) {
+ $mode = FE_STATUS;
+ next;
+ }
+ if ($mode == FE_STATUS) {
+ if (m/\} fe_status_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(FE_)([^\s,=]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+
+ $name =~ s/HAS_//;
+
+ $fe_status{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_CODERATE
+ #
+ if (m/typedef enum fe_code_rate \{/) {
+ $mode = FE_CODERATE;
+ next;
+ }
+ if ($mode == FE_CODERATE) {
+ if (m/\} fe_code_rate_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(FEC_)([^\s,]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+ $name =~ s,_,/,;
+
+ $fe_code_rate{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_MODULATION
+ #
+ if (m/typedef enum fe_modulation \{/) {
+ $mode = FE_MODULATION;
+ next;
+ }
+ if ($mode == FE_MODULATION) {
+ if (m/\} fe_modulation_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/\t([^\s,=]+)/) {
+ my $macro = "$1";
+ my $name = $1;
+ $name =~ s,_,/,;
+
+ $fe_modulation{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_TMODE
+ #
+ if (m/typedef enum fe_transmit_mode \{/) {
+ $mode = FE_TMODE;
+ next;
+ }
+ if ($mode == FE_TMODE) {
+ if (m/\} fe_transmit_mode_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(TRANSMISSION_MODE_)([^\s,=]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+ $name =~ s,_,/,;
+
+ $fe_t_mode{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_BW
+ #
+ if (m/typedef enum fe_bandwidth \{/) {
+ $mode = FE_BW;
+ next;
+ }
+ if ($mode == FE_BW) {
+ if (m/\} fe_bandwidth_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(BANDWIDTH_)([^\s]+)(_MHZ)/) {
+ my $macro = "$1$2$3";
+ my $name = $2;
+ $name =~ s,_,.,;
+ $name *= 1000000;
+
+ $fe_bw{$macro} = $name;
+ } elsif (m/(BANDWIDTH_)([^\s,=]+)/) {
+ my $macro = "$1$2$3";
+ my $name = 0;
+
+ $fe_bw{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_GINTERVAL
+ #
+ if (m/typedef enum fe_guard_interval \{/) {
+ $mode = FE_GINTERVAL;
+ next;
+ }
+ if ($mode == FE_GINTERVAL) {
+ if (m/\} fe_guard_interval_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(GUARD_INTERVAL_)([^\s,=]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+ $name =~ s,_,/,;
+
+ $fe_guard_interval{$macro} = $name;
+ }
+ }
+ #
+ # Mode FE_HIERARCHY
+ #
+ if (m/typedef enum fe_hierarchy \{/) {
+ $mode = FE_HIERARCHY;
+ next;
+ }
+ if ($mode == FE_HIERARCHY) {
+ if (m/\} fe_hierarchy_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(HIERARCHY_)([^\s,=]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+ $name =~ s,_,/,;
+
+ $fe_hierarchy{$macro} = $name;
+ }
+ }
+ #
+ # DTV macros
+ #
+ if (m/\#define\s+(DTV_)([^\s]+)\s+\d+/) {
+ next if ($2 eq "IOCTL_MAX_MSGS");
+
+ my $macro = "$1$2";
+ my $name = $2;
+ $dvb_v5{$macro} = $name;
+ }
+ #
+ # Mode FE_DTS
+ #
+ if (m/typedef enum fe_delivery_system \{/) {
+ $mode = FE_DTS;
+ next;
+ }
+ if ($mode == FE_DTS) {
+ if (m/\} fe_delivery_system_t;/) {
+ $mode = NORMAL;
+ next;
+ }
+ if (m/(SYS_)([^\s,=]+)/) {
+ my $macro = "$1$2";
+ my $name = $2;
+ $name =~ s,_,/,;
+
+ $fe_delivery_system{$macro} = $name;
+ }
+ }
+ }
+
+ close IN;
+}
+
+sub sort_func {
+ my $aa = $a;
+ my $bb = $b;
+
+ my $str_a;
+ my $str_b;
+
+ while ($aa && $bb) {
+ # Strings before a number
+ if ($aa =~ /^([^\d]+)\d/) { $str_a = $1 } else { $str_a = "" };
+ if ($bb =~ /^([^\d]+)\d/) { $str_b = $1 } else { $str_b = "" };
+ if ($str_a && $str_b) {
+ my $cmp = $str_a cmp $str_b;
+
+ return $cmp if ($cmp);
+
+ $aa =~ s/^($str_a)//;
+ $bb =~ s/^($str_b)//;
+ next;
+ }
+
+ # Numbers
+ if ($aa =~ /^(\d+)/) { $str_a = $1 } else { $str_a = "" };
+ if ($bb =~ /^(\d+)/) { $str_b = $1 } else { $str_b = "" };
+ if ($str_a && $str_b) {
+ my $cmp = $str_a <=> $str_b;
+
+ return $cmp if ($cmp);
+
+ $aa =~ s/^($str_a)//;
+ $bb =~ s/^($str_b)//;
+ next;
+ }
+ last;
+ }
+
+ return $a cmp $b;
+}
+
+sub output_arrays($$$$)
+{
+ my $name = shift;
+ my $struct = shift;
+ my $type = shift;
+ my $bitmap = shift;
+
+ my $size = keys(%$struct);
+ my $max;
+
+ return if (%$struct == 0);
+
+ $type .= " " if (!($type =~ m/\*$/));
+
+ if ($bitmap) {
+ printf OUT "struct %s {\n\t\%s idx;\n\tchar *name;\n} %s[%i] = {\n",
+ $name, $type, $name, $size;
+ } else {
+ printf OUT "const %s%s[%i] = {\n", $type, $name, $size;
+ }
+
+ foreach my $i (sort keys %$struct) {
+ my $len = length($i);
+ $max = $len if ($len > $max);
+ }
+
+ foreach my $i (sort sort_func keys %$struct) {
+ if ($bitmap) {
+ printf OUT "\t{ %s, ", $i;
+ } else {
+ printf OUT "\t[%s] = ", $i;
+ }
+ my $len = length($i);
+ while ($len < $max) {
+ print OUT " ";
+ $len++;
+ }
+ if ($bitmap) {
+ printf OUT "\"%s\" },\n", $struct->{$i};
+ } else {
+ if ($type eq "char *") {
+ printf OUT "\"%s\",\n", $struct->{$i};
+ } else {
+ printf OUT "%s,\n", $struct->{$i};
+ }
+ }
+ }
+ printf OUT "};\n\n";
+}
+
+my $fe_file = "$dir/linux/dvb/frontend.h";
+
+copy $fe_file, "dvb_frontend.h";
+
+# Generate a header file with the API conversions
+open OUT, ">dvb-v5.h" or die "Can't write on dvb-v5.h";
+gen_fe $fe_file;
+print OUT <<EOF;
+/*
+ * File auto-generated from the kernel sources. Please, don't edit it
+ */
+#ifndef _DVB_V5_CONSTS_H
+#define _DVB_V5_CONSTS_H
+#include "dvb_frontend.h"
+EOF
+output_arrays ("fe_caps_name", \%fe_caps, "unsigned", 1);
+output_arrays ("fe_status_name", \%fe_status, "unsigned", 1);
+output_arrays ("fe_code_rate_name", \%fe_code_rate, "char *", 0);
+output_arrays ("fe_modulation_name", \%fe_modulation, "char *", 0);
+output_arrays ("fe_transmission_mode_name", \%fe_t_mode, "char *", 0);
+output_arrays ("fe_bandwidth_name", \%fe_bw, "unsigned", 0);
+output_arrays ("fe_guard_interval_name", \%fe_guard_interval, "char *", 0);
+output_arrays ("fe_hierarchy_name", \%fe_hierarchy, "char *", 0);
+output_arrays ("dvb_v5_name", \%dvb_v5, "char *", 0);
+output_arrays ("delivery_system_name", \%fe_delivery_system, "char *", 0);
+printf OUT "#endif\n";
+
+close OUT;