Skip to content

Commit

Permalink
fix: fix video cards support under MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Sep 27, 2018
1 parent ada9b11 commit 9ca09d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ inventory:
* Fix #453: under MacOS, skip XML DTD validation for software inventory as
parsing may fail if a proxy is enabled
* Fix #473: fix arch detection under MacOS
* Fix #475: fix video cards support under MacOS

deploy:
* Bump Deploy task version to 2.7
Expand Down
43 changes: 28 additions & 15 deletions lib/FusionInventory/Agent/Task/Inventory/MacOS/Videos.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,51 @@ sub _getDisplays {

foreach my $videoName (keys %{$infos->{'Graphics/Displays'}}) {
my $videoCardInfo = $infos->{'Graphics/Displays'}->{$videoName};

my $memory = $videoCardInfo->{'VRAM (Total)'} ||
$videoCardInfo->{'VRAM (Dynamic, Max)'};
$memory =~ s/\ .*//g if $memory;

my $video = {
CHIPSET => $videoCardInfo->{'Chipset Model'},
MEMORY => $memory,
NAME => $videoName
};

foreach my $displayName (keys %{$videoCardInfo->{Displays}}) {
next if $displayName eq 'Display Connector';
next if $displayName eq 'Display';
my $displayInfo = $videoCardInfo->{Displays}->{$displayName};

my $resolution = $displayInfo->{Resolution};
if ($resolution) {
$resolution =~ s/\ //g;
$resolution =~ s/\@.*//g;
my ($x,$y) = $resolution =~ /(\d+) *x *(\d+)/;
$resolution = $x.'x'.$y if $x && $y;
}

my $memory = $videoCardInfo->{'VRAM (Total)'};
$memory =~ s/\ .*//g if $memory;

push @videos, {
CHIPSET => $videoCardInfo->{'Chipset Model'},
MEMORY => $memory,
NAME => $videoName,
RESOLUTION => $resolution,
PCISLOT => $videoCardInfo->{Slot}
};

my $monitor = {
CAPTION => $displayName,
DESCRIPTION => $displayName,
CAPTION => $displayName
};

my $serial = getSanitizedString($displayInfo->{'Display Serial Number'});
$monitor->{SERIAL} = $serial if $serial;

my $description = getSanitizedString($displayInfo->{'Display Type'});
$monitor->{DESCRIPTION} = $description if $description;

push @monitors, $monitor;

# Set first found resolution on associated video card
$video->{RESOLUTION} = $resolution
if $resolution && !$video->{RESOLUTION};
}

$video->{PCISLOT} = $videoCardInfo->{Bus}
if defined($videoCardInfo->{Bus});
$video->{PCISLOT} = $videoCardInfo->{Slot}
if defined($videoCardInfo->{Slot});

push @videos, $video;
}

return (
Expand Down

0 comments on commit 9ca09d0

Please sign in to comment.