summaryrefslogtreecommitdiff
path: root/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-05-27 10:01:24 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2009-05-27 10:01:24 +0000
commit18c6813f2c788b603dab363b9138d65d24252167 (patch)
tree92402484268f2bc1d5e4e55f7321b9204ad47c5f /kernel/xpp/utils/zconf/Zaptel/Hardware.pm
parent2a73224819e867eaf56371d6055e2ca4d36396b6 (diff)
Big dump of newer xpp code.
For finer details and separate commits, you are advised to look into the commit log of dahdi-{linux,tools}. xpp.r7150 * 116x Astribanks: - Support for the TwinStar capability and for FXO and (BRI|PRI) on same device. - New control protocol ("MPP"). - astribank_hextool - a low-level firmware loading tool instead of fpga_load . - astribank_tool - Other MPP activities . - Can still reset (but just that) through older protocol. - astribank_hexload is required for loading FPGA firmware for USB_FW.hex rev > 6885. - USB_FW rev. 7071 . - More modular FPGA firmware (1161 only). - FPGA_1161.hex rev. 7131. PIC_TYPE_* rev. 7107. - software-settings of some capabilities with astribank_allow . * XPP: - init_card_* script are less verbose. - Reduced rate of "Is a DAHDI sync master" message. - Replace member bus_id with dev_name() and set_dev_name() for building with 2.6.30. - Conditionally remove 'owner' property of procfs was dropped in 2.6.30. - astribank_hook now enabled by default. - Has an optional hook for TwinStar. * BRI: - hardhdlc support: The bri_dchan patch is no longer needed. - If bri_dchan patch applied: old code is used, and "dchan" is used. - If not: new code and "hardhdlc" is used. - zapconf will generate the right configuration, depending on the new sysfs driver attribute bri_hardhdlc, but default to "dchan" as before if not explicitly told. - Bugfix: explicitly turn off leds on startup. * FXS: - Initialization and calibration fixes. - Notify the user just one about wrong VMWI config * Dahdi-perl: - Fix detection of empty slots in wctdm. - Fix working with ethmf's extra file in /proc/zaptel - Improved detection of Rhino cards. - dahdi_genconf's generated text better explains files are generated. - /etc/xpp_order - allow specifiying an explicit order for Astribanks to register with Zaptel. - Dahdi::Xpp::Mpp - A wrapper around astribank_tool . * dahdi.init: - A separate waitfor_xpds script. May now have a wait-loop in some cases. - xpp_sync needs to only be called after dahdi_cfg . (for the PRI module). git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4641 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'kernel/xpp/utils/zconf/Zaptel/Hardware.pm')
-rw-r--r--kernel/xpp/utils/zconf/Zaptel/Hardware.pm95
1 files changed, 74 insertions, 21 deletions
diff --git a/kernel/xpp/utils/zconf/Zaptel/Hardware.pm b/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
index ff7aeea..b12368b 100644
--- a/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
+++ b/kernel/xpp/utils/zconf/Zaptel/Hardware.pm
@@ -8,8 +8,6 @@ package Zaptel::Hardware;
# $Id$
#
use strict;
-use Zaptel::Hardware::USB;
-use Zaptel::Hardware::PCI;
=head1 NAME
@@ -44,6 +42,7 @@ system. It identifies devices by (USB/PCI) bus IDs.
=head1 Device Attributes
+
As usual, object attributes can be used in either upp-case or
lower-case, or lower-case functions.
@@ -92,22 +91,27 @@ attributes).
Astribank.
=cut
+#
+# A global hardware handle
+#
-sub device_detected($$) {
- my $dev = shift || die;
- my $name = shift || die;
- die unless defined $dev->{'BUS_TYPE'};
+my %hardware_list = (
+ 'PCI' => [],
+ 'USB' => [],
+ );
+
+
+sub new($$) {
+ my $pack = shift || die "Wasn't called as a class method\n";
+ my $name = shift || die "$0: Missing device name";
+ my $type = shift || die "$0: Missing device type";
+ my $dev = {};
+ $dev->{'BUS_TYPE'} = $type;
$dev->{IS_ASTRIBANK} = 0 unless defined $dev->{'IS_ASTRIBANK'};
$dev->{'HARDWARE_NAME'} = $name;
+ return $dev;
}
-sub device_removed($) {
- my $dev = shift || die;
- my $name = $dev->hardware_name;
- die "Missing zaptel device hardware name" unless $name;
-}
-
-
=head1 device_list()
Returns a list of the hardware devices on the system.
@@ -117,17 +121,28 @@ You must run scan() first for this function to run meaningful output.
=cut
sub device_list($) {
- my $self = shift || die;
+ my $pack = shift || die;
my @types = @_;
my @list;
@types = qw(USB PCI) unless @types;
foreach my $t (@types) {
- @list = ( @list, @{$self->{$t}} );
+ my $lst = $hardware_list{$t};
+ @list = ( @list, @{$lst} );
}
return @list;
}
+sub device_by_hwname($$) {
+ my $pack = shift || die;
+ my $name = shift || die;
+ my @list = device_list('localcall');
+
+ my @good = grep { $_->hardware_name eq $name } @list;
+ return undef unless @good;
+ @good > 1 && die "$pack: Multiple matches for '$name': @good";
+ return $good[0];
+}
=head1 drivers()
@@ -139,7 +154,7 @@ loaded.
sub drivers($) {
my $self = shift || die;
- my @devs = $self->device_list;
+ my @devs = device_list('localcall');
my @drvs = map { $_->{DRIVER} } @devs;
# Make unique
my %drivers;
@@ -155,14 +170,52 @@ must be run to initialize the module.
=cut
+my $hardware_scanned;
+
sub scan($) {
my $pack = shift || die;
- my $self = {};
- bless $self, $pack;
- $self->{USB} = [ Zaptel::Hardware::USB->devices ];
- $self->{PCI} = [ Zaptel::Hardware::PCI->scan_devices ];
- return $self;
+ return if $hardware_scanned++;
+ foreach my $type (qw(PCI USB)) {
+ eval "use Zaptel::Hardware::$type";
+ die $@ if $@;
+ $hardware_list{$type} = [ "Zaptel::Hardware::$type"->scan_devices ];
+ }
+}
+
+sub import {
+ Zaptel::Hardware->scan unless grep(/\bnoscan\b/i, @_);
+}
+
+sub showall {
+ my $pack = shift || die;
+ my @devs;
+
+ my $printer = sub {
+ my $title = shift;
+ my @devs = @_;
+
+ return unless @devs;
+ printf "%s:\n", $title;
+ foreach my $dev (@devs) {
+ printf "\t%s\n", $dev->hardware_name;
+ foreach my $k (sort keys %{$dev}) {
+ my $v = $dev->{$k};
+ if($k eq 'MPPINFO') {
+ printf "\t\tMPPINFO:\n";
+ eval "use Zaptel::Xpp::Mpp";
+ die $@ if $@;
+ $v->showinfo("\t\t ");
+ } else {
+ printf "\t\t%-20s %s\n", $k, $v;
+ }
+ }
+ }
+ };
+ foreach my $type (qw(USB PCI)) {
+ my $lst = $hardware_list{$type};
+ &$printer("$type devices", @{$lst});
+ }
}
1;