1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
#!/usr/bin/perl
use FileHandle;
my %depend = ();
my %minver = ();
my %config = ();
my %intopt = ();
my %tristate = ();
my $version, $level, $sublevel;
my $force_kconfig=shift;
sub add_bool($)
{
my $arg=shift;
exists $config{$arg} or die "Adding unknown boolean '$arg'";
$tristate{$arg}="bool";
# printf "Boolean:%s\n",$arg;
}
sub add_tristate($)
{
my $arg=shift;
exists $config{$arg} or die "Adding unknown tristate '$arg'";
$tristate{$arg}="tristate";
# printf "Tristate:%s\n",$arg;
}
sub add_int($)
{
my $arg=shift;
exists $config{$arg} or die "Adding unknown int/hex '$arg'";
$intopt{$arg} = 0;
}
sub set_int_value($$)
{
my $key = shift;
my $val = shift;
exists $intopt{$key} or die "Default for unknown int/hex option '$key'";
$intopt{$key} = $val;
}
sub add_config($)
{
my $arg=shift;
if ($arg =~ m/^(\w+)/) {
# Have option default to 'on'
$config{$1} = 1;
} else {
die "Do not understand config variable '$arg'";
}
}
# Turn option off, iff it already exists
sub disable_config($)
{
my $key = shift;
$config{$key} = 0 if (exists $config{$key});
}
sub check_deps($)
{
my $arg=shift;
$arg=$arg." ";
while ($arg ne "") {
if ($arg =~ m/^([A-Z0-9_]+) /) {
my $val=$1;
my $prev=$depend{$val};
$depend { $val } = 1+$prev;
}
$arg =~ s/^[^ ]+ //;
}
}
sub open_kconfig($$) {
my ($dir,$file)=@_;
my $in = new FileHandle;
my $disabled=0;
my $key;
#print "opening $file\n";
open $in,"$file";
while (<$in>) {
# if (m;^\s*source[\s\"]+drivers/media/(video|dvb)/Kconfig;) {
# next;
# }
# start of a new stanza, reset
if (m/^\w/) {
$disabled = 0;
$default_seen = 0;
$key = undef;
}
if (m|^\s*source\s+"([^"]+)"\s*$| ||
m|^\s*source\s+(\S+)\s*$|) {
open_kconfig($dir,"$dir/$1");
next;
}
if (m|^\s+depends on\s+(.*)\n|) {
check_deps ($1);
}
if (m|^\s+select\s+(.*)\n|) {
check_deps ($1);
}
if (m|^\s+bool(ean)?\s|) {
add_bool($key);
}
if (m|^\s+tristate\s|) {
add_tristate($key);
}
if (m|^\s+int\s|) {
add_int($key);
}
if (m|^\s+hex\s|) {
add_int($key);
}
# Get default for int options
if (m|^\s+default "([[:xdigit:]]+)"| && exists $intopt{$key}) {
set_int_value($key, $1);
}
# Override default for disabled tri/bool options
if (m/^\s+default (y|n|m|"yes"|"no")\s+(if .*)?$/ &&
exists $tristate{$key} && $disabled) {
$default_seen = 1;
$_ = "\tdefault n\n";
}
# check for end of config definition for disabled drivers
# we need to make sure we've disabled it, and add a bit
# to the help text
if (m|^\s*(---)?help(---)?\s*$| && $disabled) {
if(exists $tristate{$key} && !$default_seen) {
print OUT "\tdefault n\n";
}
print OUT <<"EOF";
depends on VIDEO_KERNEL_VERSION
help
WARNING! This driver needs at least kernel $minver{$key}! It may not
compile or work correctly on your kernel, which is too old.
EOF
next;
}
if (m|^\s*config (\w+)\s*$|) {
$key=$1;
add_config ($1);
my $min=$minver { $key };
my $minversion, $minlevel, $minsublevel;
if ($min =~ m/(\d+)\.(\d+)\.(\d+)/) {
$minversion=$1;
$minlevel=$2;
$minsublevel=$3;
} else {
die "Minimum version for $key not found at versions.txt";
}
if ( ($version < $minversion) ||
($level < $minlevel) ||
($sublevel < $minsublevel) ) {
$disabled=1;
disable_config ($key);
print "$key requires version $minversion.$minlevel.$minsublevel\n";
print OUT "# $key disabled for insufficient kernel version\n";
} else {
# print "OK: $key requires version $minversion.$minlevel.$minsublevel\n";
$disabled=0;
}
}
s/^main(menu\s\"[^\"]+)/\1 - DON'T CHANGE IT!/;
print OUT $_;
}
close $in;
}
sub parse_versions ()
{
my $in = new FileHandle;
my $ver;
open $in,"versions.txt";
while (<$in>) {
if (m/\[([\d.]*)\]/) {
$ver=$1;
next;
}
s/\n//;
if (m/^\s*([\w\d_]+)/) {
$minver { $1 } = $ver;
# printf ("%s=%s\n",$1,$ver);
}
}
close $in;
}
parse_versions;
open IN,".version";
while (<IN>) {
if (m/KERNELRELEASE\s*[:]*[=]+\s*(\d+)\.(\d+)\.(\d+)/) {
$version=$1;
$level=$2;
$sublevel=$3;
}
}
close IN;
printf "Preparing to compile for kernel version %d.%d.%d\n",$version,$level,$sublevel;
open OUT,">Kconfig";
print OUT <<"EOF";
mainmenu "V4L/DVB menu"
source Kconfig.kern
config VIDEO_KERNEL_VERSION
bool "Enable drivers not supported by this kernel"
default n
---help---
Normally drivers that require a kernel newer $version.$level.$sublevel,
the kernel you are compiling for now, will be disabled.
Turning this switch on will let you enabled them, but be warned
they may not work properly or even compile.
They may also work fine, and the only reason they are listed as
requiring a newer kernel is that no one has tested them with an
older one yet.
If the driver works, please post a report at V4L mailing list:
video4linux-list\@redhat.com.
Unless you know what you are doing, you should answer N.
EOF
open_kconfig ("../linux","../linux/drivers/media/Kconfig");
close OUT;
while ( my ($key, $value) = each(%config) ) {
delete $depend{$key};
}
open OUT,">Kconfig.kern";
print OUT "config MODULES\n\tboolean\n\tdefault y\n\n";
add_config('MODULES');
add_bool('MODULES');
while ( my ($key, $value) = each(%depend) ) {
print OUT "# $key with $value refs\nconfig $key\n\ttristate\n\tdefault m\n\n";
}
close OUT;
# These options should default to off
disable_config('DVB_AV7110_FIRMWARE');
disable_config('DVB_CINERGYT2_TUNING');
# Produce a .config file if it's forced or one doesn't already exist
if (($force_kconfig eq 1) || !open IN,".config") {
open OUT,">.config";
while ( my ($key,$value) = each(%tristate) ) {
if (!$config{$key}) {
print OUT "CONFIG_$key=n\n";
} elsif ($value eq 'tristate') {
print OUT "CONFIG_$key=m\n";
} else { # must be 'bool'
print OUT "CONFIG_$key=y\n";
}
}
while ( my ($key,$value) = each(%intopt) ) {
print OUT "CONFIG_$key=$value\n";
}
close OUT;
}
|