Skip to content

Commit

Permalink
Merge pull request #28 from mithro/master
Browse files Browse the repository at this point in the history
Couple of small fixes
  • Loading branch information
mithro committed Aug 6, 2016
2 parents d0eb917 + e82bd59 commit 080cd63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
29 changes: 18 additions & 11 deletions hdmi2usb/modeswitch/boards.py
Expand Up @@ -26,17 +26,24 @@ def assert_in(needle, haystack):
assert needle in haystack, "%r not in %r" % (needle, haystack)


__filepath__ = os.path.dirname(__file__)
FIRMWARE_DIR = os.path.abspath(os.path.realpath(
os.path.join(__filepath__, '..', 'firmware')))
assert os.path.exists(FIRMWARE_DIR)


def firmware_path(filepath):
ourpath = os.path.dirname(__file__)
firmwaredir = os.path.abspath(os.path.realpath(
os.path.join(ourpath, '..', 'firmware')))
assert os.path.exists(firmwaredir)
locations = ['']
locations.append(os.getcwd())
locations.append(FIRMWARE_DIR)

for loc in locations:
fullname = os.path.join(loc, filepath)
fullname = os.path.abspath(os.path.realpath(fullname))
if os.path.exists(fullname):
return fullname

# FIXME: On Linux we should check "/lib/firmware/" too?
fullname = os.path.join(firmwaredir, filepath)
fullname = os.path.abspath(os.path.realpath(fullname))
assert os.path.exists(fullname), fullname
return fullname
assert False, "{} not found in {}".format(filepath, locations)


BOARD_TYPES = [
Expand Down Expand Up @@ -136,7 +143,7 @@ def load_fpga(board, filename, verbose=False):
assert not board.dev.inuse()
assert board.type in OPENOCD_MAPPING

filepath = os.path.abspath(filename)
filepath = firmware_path(filename)
assert os.path.exists(filepath), filepath
assert filename.endswith(".bit"), "Loading requires a .bit file"
xfile = files.XilinxBitFile(filepath)
Expand Down Expand Up @@ -169,7 +176,7 @@ def flash_fpga(board, filename, verbose=False):
assert not board.dev.inuse()
assert board.type in OPENOCD_MAPPING

filepath = os.path.abspath(filename)
filepath = firmware_path(filename)
assert os.path.exists(filepath), filepath
assert filename.endswith(".bin"), "Flashing requires a .bin file"
xfile = files.XilinxBinFile(filepath)
Expand Down
6 changes: 3 additions & 3 deletions udev/99-hdmi2usb-permissions.rules
Expand Up @@ -15,12 +15,12 @@ SUBSYSTEM=="video4linux", ENV{ID_HDMI2USB}=="1", \
# Allow the user to unbind the kernel drivers attached to the device
SUBSYSTEM=="usb", DRIVER=="usb", ENV{ID_HDMI2USB}=="1", \
TEST=="$sys$env{DEVPATH}/driver/unbind" \
RUN+="chmod 0666 $sys$env{DEVPATH}/driver/unbind"
RUN+="/bin/chmod 0666 $sys$env{DEVPATH}/driver/unbind"

SUBSYSTEM=="tty", ENV{ID_HDMI2USB}=="1", \
TEST=="$sys$env{DEVPATH}/../../driver/unbind" \
RUN+="chmod 0666 $sys$env{DEVPATH}/../../driver/unbind"
RUN+="/bin/chmod 0666 $sys$env{DEVPATH}/../../driver/unbind"

SUBSYSTEM=="video4linux", ENV{ID_HDMI2USB}=="1", \
TEST=="$sys$env{DEVPATH}/driver/unbind" \
RUN+="chmod 0666 $sys$env{DEVPATH}/../../driver/unbind"
RUN+="/bin/chmod 0666 $sys$env{DEVPATH}/../../driver/unbind"

0 comments on commit 080cd63

Please sign in to comment.