diff options
author | N.N. <matju@users.sourceforge.net> | 2008-04-28 18:10:15 +0000 |
---|---|---|
committer | N.N. <matju@users.sourceforge.net> | 2008-04-28 18:10:15 +0000 |
commit | 91c0003b158e5f0ed9d0677fb136ae8bb6f86ec5 (patch) | |
tree | d413a48086819f6a2620cd27d030861d122d4f3f /externals/gridflow/devices4ruby | |
parent | 98dfdfa2fc1c92ba69e33fd77ed3392034297c1f (diff) |
this is an old gridflow, and there's already a svn repository at http://gridflow.ca/svn/trunk
svn path=/trunk/; revision=9739
Diffstat (limited to 'externals/gridflow/devices4ruby')
-rw-r--r-- | externals/gridflow/devices4ruby/ChangeLog | 12 | ||||
-rw-r--r-- | externals/gridflow/devices4ruby/ParallelPort.rb | 72 | ||||
-rw-r--r-- | externals/gridflow/devices4ruby/README | 27 | ||||
-rw-r--r-- | externals/gridflow/devices4ruby/SoundMixer.rb | 152 | ||||
-rw-r--r-- | externals/gridflow/devices4ruby/SoundPCM.rb | 102 | ||||
-rw-r--r-- | externals/gridflow/devices4ruby/extconf.rb | 112 | ||||
-rw-r--r-- | externals/gridflow/devices4ruby/ioctl.rb | 66 |
7 files changed, 0 insertions, 543 deletions
diff --git a/externals/gridflow/devices4ruby/ChangeLog b/externals/gridflow/devices4ruby/ChangeLog deleted file mode 100644 index eb64908f..00000000 --- a/externals/gridflow/devices4ruby/ChangeLog +++ /dev/null @@ -1,12 +0,0 @@ -/* $Id: ChangeLog,v 1.1 2005-10-04 02:12:44 matju Exp $ */ - -version 0.1.1 (2002.07.29): - * module Linux::SoundDSP renamed to Linux::SoundPCM (with alias) - * added installer (ruby extconf.rb && make install) - -version 0.1 (2001.06.28): - * added module IoctlClass, Ioctl - * added module Linux::SoundDSP (4 accessors) - * added module Linux::SoundMixer (25 accessors) - * added module Linux::ParallelPort (2 readers, 2 writers) - diff --git a/externals/gridflow/devices4ruby/ParallelPort.rb b/externals/gridflow/devices4ruby/ParallelPort.rb deleted file mode 100644 index 10188592..00000000 --- a/externals/gridflow/devices4ruby/ParallelPort.rb +++ /dev/null @@ -1,72 +0,0 @@ -require "linux/ioctl" -# Copyright (c) 2001, 2003 by Mathieu Bouchard -# this is published under the Ruby license - -=begin - if using a DB-25 female connector as found on a PC, - then the pin numbering is like: - 13 _____ 1 - 25 \___/ 14 - - 1 = STROBE = the clock line is a square wave, often at 9600 Hz, - which determines the data rate in usual circumstances. - 2..9 = D0..D7 = the eight ordinary data bits - 10 = -ACK (status bit 6 ?) - 11 = BUSY (status bit 7) - 12 = PAPER_END (status bit 5) - 13 = SELECT (status bit 4 ?) - 14 = -AUTOFD - 15 = -ERROR (status bit 3 ?) - 16 = -INIT - 17 = -SELECT_IN - 18..25 = GROUND -=end - -module Linux; module ParallelPort - extend IoctlClass - - @port_flags = %w[ - LP_EXIST - LP_SELEC - LP_BUSY - LP_OFFL - LP_NOPA - LP_ERR - LP_ABORT - LP_CAREFUL - LP_ABORTOPEN - LP_TRUST_IRQ - ] - - @port_status = %w[ - nil, - nil, - nil, - LP_PERRORP # unchanged input, active low - LP_PSELECD # unchanged input, active high - LP_POUTPA # unchanged input, active high - LP_PACK # unchanged input, active low - LP_PBUSY # inverted input, active high - ] - - LPCHAR = 0x0601 - LPTIME = 0x0602 - LPABORT = 0x0604 - LPSETIRQ = 0x0605 - LPGETIRQ = 0x0606 - LPWAIT = 0x0608 - LPCAREFUL = 0x0609 # obsoleted??? wtf? - LPABORTOPEN = 0x060a - LPGETSTATUS = 0x060b # return LP_S(minor) - LPRESET = 0x060c # reset printer - LPGETSTATS = 0x060d # struct lp_stats (most likely turned off) - LPGETFLAGS = 0x060e # get status flags - LPTRUSTIRQ = 0x060f # set/unset the LP_TRUST_IRQ flag - - ioctl_reader :port_flags , :LPGETFLAGS - ioctl_reader :port_status, :LPGETSTATUS - ioctl_writer :port_careful,:LPCAREFUL - ioctl_writer :port_char, :LPCHAR - -end end - diff --git a/externals/gridflow/devices4ruby/README b/externals/gridflow/devices4ruby/README deleted file mode 100644 index 740b5165..00000000 --- a/externals/gridflow/devices4ruby/README +++ /dev/null @@ -1,27 +0,0 @@ -devices/linux - -AUTHOR - - Mathieu Bouchard <matju@sympatico.ca> - irc: irc.openprojects.net / #ruby-lang / matju - (note: I can't read Japanese; write in French or English please) - -OVERVIEW - -This is a collection of simple modules that you extend IO objects with, to -give them support for specific devices. For example: - - require "linux/SoundMixer" - f = File.open "/dev/mixer" - f.extend Linux::SoundMixer - - # f now has special accessors for driver variables, e.g: - - f.treble = left_speaker_percent + 256 * right_speaker_percent - -The modules are made of automatically generated methods, much like Ruby's -accessors. those generators are called ioctl_reader, ioctl_writer, -ioctl_accessor. Writing expects an integer in -2**31...2**31; reading will -return the same. You may browse the source to find out which accessors are -available, and it's easy to add support for more features. - diff --git a/externals/gridflow/devices4ruby/SoundMixer.rb b/externals/gridflow/devices4ruby/SoundMixer.rb deleted file mode 100644 index 0ae50b60..00000000 --- a/externals/gridflow/devices4ruby/SoundMixer.rb +++ /dev/null @@ -1,152 +0,0 @@ -require "linux/ioctl" - -module Linux; module SoundMixer - extend IoctlClass - - MIXER_NRDEVICES = 0x00000019 - MIXER_VOLUME = 0x00000000 - MIXER_BASS = 0x00000001 - MIXER_TREBLE = 0x00000002 - MIXER_SYNTH = 0x00000003 - MIXER_PCM = 0x00000004 - MIXER_SPEAKER = 0x00000005 - MIXER_LINE = 0x00000006 - MIXER_MIC = 0x00000007 - MIXER_CD = 0x00000008 - MIXER_IMIX = 0x00000009 - MIXER_ALTPCM = 0x0000000a - MIXER_RECLEV = 0x0000000b - MIXER_IGAIN = 0x0000000c - MIXER_OGAIN = 0x0000000d - MIXER_LINE1 = 0x0000000e - MIXER_LINE2 = 0x0000000f - MIXER_LINE3 = 0x00000010 - MIXER_DIGITAL1 = 0x00000011 - MIXER_DIGITAL2 = 0x00000012 - MIXER_DIGITAL3 = 0x00000013 - MIXER_PHONEIN = 0x00000014 - MIXER_PHONEOUT = 0x00000015 - MIXER_VIDEO = 0x00000016 - MIXER_RADIO = 0x00000017 - MIXER_MONITOR = 0x00000018 - ONOFF_MIN = 0x0000001c - ONOFF_MAX = 0x0000001e - MIXER_NONE = 0x0000001f - MIXER_ENHANCE = 0x0000001f - MIXER_MUTE = 0x0000001f - MIXER_LOUD = 0x0000001f - MIXER_RECSRC = 0x000000ff - MIXER_DEVMASK = 0x000000fe - MIXER_RECMASK = 0x000000fd - MIXER_CAPS = 0x000000fc - MIXER_STEREODEVS = 0x000000fb - MIXER_OUTSRC = 0x000000fa - MIXER_OUTMASK = 0x000000f9 - MASK_VOLUME = 0x00000001 - MASK_BASS = 0x00000002 - MASK_TREBLE = 0x00000004 - MASK_SYNTH = 0x00000008 - MASK_PCM = 0x00000010 - MASK_SPEAKER = 0x00000020 - MASK_LINE = 0x00000040 - MASK_MIC = 0x00000080 - MASK_CD = 0x00000100 - MASK_IMIX = 0x00000200 - MASK_ALTPCM = 0x00000400 - MASK_RECLEV = 0x00000800 - MASK_IGAIN = 0x00001000 - MASK_OGAIN = 0x00002000 - MASK_LINE1 = 0x00004000 - MASK_LINE2 = 0x00008000 - MASK_LINE3 = 0x00010000 - MASK_DIGITAL1 = 0x00020000 - MASK_DIGITAL2 = 0x00040000 - MASK_DIGITAL3 = 0x00080000 - MASK_PHONEIN = 0x00100000 - MASK_PHONEOUT = 0x00200000 - MASK_RADIO = 0x00800000 - MASK_VIDEO = 0x00400000 - MASK_MONITOR = 0x01000000 - MASK_MUTE = 0x80000000 - MASK_ENHANCE = 0x80000000 - MASK_LOUD = 0x80000000 - MIXER_READ_VOLUME = 0x80044d00 - MIXER_READ_BASS = 0x80044d01 - MIXER_READ_TREBLE = 0x80044d02 - MIXER_READ_SYNTH = 0x80044d03 - MIXER_READ_PCM = 0x80044d04 - MIXER_READ_SPEAKER = 0x80044d05 - MIXER_READ_LINE = 0x80044d06 - MIXER_READ_MIC = 0x80044d07 - MIXER_READ_CD = 0x80044d08 - MIXER_READ_IMIX = 0x80044d09 - MIXER_READ_ALTPCM = 0x80044d0a - MIXER_READ_RECLEV = 0x80044d0b - MIXER_READ_IGAIN = 0x80044d0c - MIXER_READ_OGAIN = 0x80044d0d - MIXER_READ_LINE1 = 0x80044d0e - MIXER_READ_LINE2 = 0x80044d0f - MIXER_READ_LINE3 = 0x80044d10 - MIXER_READ_MUTE = 0x80044d1f - MIXER_READ_ENHANCE = 0x80044d1f - MIXER_READ_LOUD = 0x80044d1f - MIXER_READ_RECSRC = 0x80044dff - MIXER_READ_DEVMASK = 0x80044dfe - MIXER_READ_RECMASK = 0x80044dfd - MIXER_READ_STEREODEVS = 0x80044dfb - MIXER_READ_CAPS = 0x80044dfc - MIXER_WRITE_VOLUME = 0xc0044d00 - MIXER_WRITE_BASS = 0xc0044d01 - MIXER_WRITE_TREBLE = 0xc0044d02 - MIXER_WRITE_SYNTH = 0xc0044d03 - MIXER_WRITE_PCM = 0xc0044d04 - MIXER_WRITE_SPEAKER = 0xc0044d05 - MIXER_WRITE_LINE = 0xc0044d06 - MIXER_WRITE_MIC = 0xc0044d07 - MIXER_WRITE_CD = 0xc0044d08 - MIXER_WRITE_IMIX = 0xc0044d09 - MIXER_WRITE_ALTPCM = 0xc0044d0a - MIXER_WRITE_RECLEV = 0xc0044d0b - MIXER_WRITE_IGAIN = 0xc0044d0c - MIXER_WRITE_OGAIN = 0xc0044d0d - MIXER_WRITE_LINE1 = 0xc0044d0e - MIXER_WRITE_LINE2 = 0xc0044d0f - MIXER_WRITE_LINE3 = 0xc0044d10 - MIXER_WRITE_MUTE = 0xc0044d1f - MIXER_WRITE_ENHANCE = 0xc0044d1f - MIXER_WRITE_LOUD = 0xc0044d1f - MIXER_WRITE_RECSRC = 0xc0044dff - MIXER_INFO = 0x805c4d65 - MIXER_ACCESS = 0xc0804d66 - MIXER_AGC = 0xc0044d67 - MIXER_3DSE = 0xc0044d68 - MIXER_PRIVATE1 = 0xc0044d6f - MIXER_PRIVATE2 = 0xc0044d70 - MIXER_PRIVATE3 = 0xc0044d71 - MIXER_PRIVATE4 = 0xc0044d72 - MIXER_PRIVATE5 = 0xc0044d73 - MIXER_GETLEVELS = 0xc0a44d74 - MIXER_SETLEVELS = 0xc0a44d75 - - DEVICE_LABELS = [ - "Vol ", "Bass ", "Trebl", "Synth", "Pcm ", - "Spkr ","Line ", "Mic ", "CD ", "Mix ", - "Pcm2 ","Rec ", "IGain", "OGain", - "Line1", "Line2", "Line3", "Digital1", "Digital2", "Digital3", - "PhoneIn", "PhoneOut", "Video", "Radio", "Monitor" - ] - - DEVICE_NAMES = [ - "vol", "bass", "treble", "synth", "pcm", "speaker", "line", - "mic", "cd", "mix", "pcm2", "rec", "igain", "ogain", - "line1", "line2", "line3", "dig1", "dig2", "dig3", - "phin", "phout", "video", "radio", "monitor" - ] - - DEVICE_NAMES.each_with_index {|name,i| - ioctl_accessor name, - MIXER_READ_VOLUME+i, - MIXER_WRITE_VOLUME+i - } - -end end diff --git a/externals/gridflow/devices4ruby/SoundPCM.rb b/externals/gridflow/devices4ruby/SoundPCM.rb deleted file mode 100644 index d1b97159..00000000 --- a/externals/gridflow/devices4ruby/SoundPCM.rb +++ /dev/null @@ -1,102 +0,0 @@ -# $Id: SoundPCM.rb,v 1.1 2005-10-04 02:02:14 matju Exp $ -require "linux/ioctl" - -module Linux - -module SoundPCM - extend IoctlClass - - # SNDCTL Kernel Procedure Numbers - - SEQ_RESET = 0x00005100 - SEQ_SYNC = 0x00005101 - SEQ_CTRLRATE = 0xc0045103 - SEQ_GETOUTCOUNT = 0x80045104 - SEQ_GETINCOUNT = 0x80045105 - SEQ_PERCMODE = 0x40045106 - SEQ_TESTMIDI = 0x40045108 - SEQ_RESETSAMPLES = 0x40045109 - SEQ_NRSYNTHS = 0x8004510a - SEQ_NRMIDIS = 0x8004510b - SEQ_THRESHOLD = 0x4004510d - SEQ_PANIC = 0x00005111 - SEQ_OUTOFBAND = 0x40085112 - SEQ_GETTIME = 0x80045113 - - SYNTH_INFO = 0xc08c5102 - SYNTH_MEMAVL = 0xc004510e - SYNTH_ID = 0xc08c5114 - SYNTH_CONTROL = 0xcfa45115 - SYNTH_REMOVESAMPLE = 0xc00c5116 - - FM_LOAD_INSTR = 0x40285107 - FM_4OP_ENABLE = 0x4004510f - - TMR_TIMEBASE = 0xc0045401 - TMR_START = 0x00005402 - TMR_STOP = 0x00005403 - TMR_CONTINUE = 0x00005404 - TMR_TEMPO = 0xc0045405 - TMR_SOURCE = 0xc0045406 - TMR_METRONOME = 0x40045407 - TMR_SELECT = 0x40045408 - - MIDI_INFO = 0xc074510c - MIDI_PRETIME = 0xc0046d00 - MIDI_MPUMODE = 0xc0046d01 - MIDI_MPUCMD = 0xc0216d02 - - # DSP_* names are obsolete ? - DSP_STEREO = 0xc0045003 - DSP_GETBLKSIZE = 0xc0045004 - DSP_SETDUPLEX = 0x00005016 - DSP_GETODELAY = 0x80045017 - DSP_PROFILE = 0x40045017 - - # what is this? - COPR_RESET = 0x00004300 - COPR_LOAD = 0xcfb04301 - COPR_RDATA = 0xc0144302 - COPR_RCODE = 0xc0144303 - COPR_WDATA = 0x40144304 - COPR_WCODE = 0x40144305 - COPR_RUN = 0xc0144306 - COPR_HALT = 0xc0144307 - COPR_SENDMSG = 0xcfa44308 - COPR_RCVMSG = 0x8fa44309 - - # SOUND_PCM Kernel Procedure Numbers - - PCM_READ_BITS , PCM_WRITE_BITS = 0x80045005, 0xc0045005 - PCM_READ_CHANNELS , PCM_WRITE_CHANNELS = 0x80045006, 0xc0045006 - PCM_READ_FILTER , PCM_WRITE_FILTER = 0x80045007, 0xc0045007 - PCM_READ_RATE , PCM_WRITE_RATE = 0x80045002, 0xc0045002 - - PCM_RESET = 0x00005000 - PCM_SYNC = 0x00005001 - PCM_POST = 0x00005008 - PCM_SUBDIVIDE = 0xc0045009 - PCM_SETFRAGMENT = 0xc004500a - PCM_GETFMTS = 0x8004500b - PCM_SETFMT = 0xc0045005 - PCM_GETOSPACE = 0x8010500c - PCM_GETISPACE = 0x8010500d - PCM_NONBLOCK = 0x0000500e - PCM_GETCAPS = 0x8004500f - PCM_GETTRIGGER , PCM_SETTRIGGER = 0x80045010, 0x40045010 - PCM_SETSYNCRO = 0x00005015 - PCM_GETIPTR = 0x800c5011 - PCM_GETOPTR = 0x800c5012 - PCM_MAPINBUF = 0x80085013 - PCM_MAPOUTBUF = 0x80085014 - - ioctl_accessor :bits , :PCM_READ_BITS , :PCM_WRITE_BITS - ioctl_accessor :channels, :PCM_READ_CHANNELS, :PCM_WRITE_CHANNELS - ioctl_accessor :filter , :PCM_READ_FILTER , :PCM_WRITE_FILTER - ioctl_accessor :rate , :PCM_READ_RATE , :PCM_WRITE_RATE -end - -# backward compatibility -SoundDSP = SoundPCM - -end # Linux diff --git a/externals/gridflow/devices4ruby/extconf.rb b/externals/gridflow/devices4ruby/extconf.rb deleted file mode 100644 index 9e49cbdc..00000000 --- a/externals/gridflow/devices4ruby/extconf.rb +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env ruby -# $Id: extconf.rb,v 1.1 2005-10-04 02:02:14 matju Exp $ -# installer for RubyX11 / MetaRuby / etc -# by Mathieu Bouchard - -require "rbconfig" -require "ftools" -include Config - -$DESTDIR = "#{CONFIG["sitedir"]}/#{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}" -#$DESTDIR = "/home/matju/lib/ruby/#{RUBY_VERSION[0,3]}" -$RUBY = "ruby" - -while ARGV.length>0 - arg=ARGV.shift - case arg - when /=/ - i=arg.index '=' - ARGV.unshift arg[0..i-1], arg[i+1..-1] - when "--prefix" - $DESTDIR = ARGV.shift + "/lib/ruby/#{CONFIG["MAJOR"]}.#{CONFIG["MINOR"]}" - end -end - - - -def install_files(f,base,entries) - entries.each {|type,name,*rest| - case type - when :ruby - f.puts "\tinstall -m644 #{base+name} $(DESTDIR)/#{base+name}" - when :directory - f.puts "\t@mkdir $(DESTDIR)/#{base+name} || true" - install_files(f,base+name,rest) - end - } -end - -def uninstall_files(f,base,entries) - entries.each {|type,name,*rest| - case type - when :ruby - f.puts "\trm $(DESTDIR)/#{base+name}" - when :directory - uninstall_files(f,base+name,rest) - end - } -end - -def make_makefile - File.open("Makefile","w") {|f| - f.puts "# Warning: this file is GENERATED by ./extconf.rb", "" - f.puts "DESTDIR = #{$DESTDIR}", "" - f.puts "RUBY = #{$RUBY}" - f.puts "all::", "" - f.puts "Makefile: extconf.rb" - f.puts "\t$(RUBY) extconf.rb", "" - - f.puts "install::" - f.puts "\t@mkdir -p $(DESTDIR)" - install_files(f,"",FILES) - f.puts - f.puts "uninstall::" - uninstall_files(f,"",FILES) - f.puts - } - #FILES.each {|name| - # File.install "lib/#{name}", "#{DSTPATH}/#{name}", 0644, true - #end -end - -#----------------------------------------------------------------# - -$DESTDIR += "/linux/" #(HACK!) - -FILES = [ -# [:directory, "linux/", - [:ruby, "ioctl.rb"], - [:ruby, "SoundPCM.rb"], - [:ruby, "ParallelPort.rb"], - [:ruby, "SoundMixer.rb"], -# ] -] - -make_makefile - - -__END__ -### the following is discarded (just a test) - -require "mkmf" - -srcs = %w( - termios -) - -#have_library("m") -#have_func("sincos") -#have_func("asinh") - -#if have_header("fftw.h") -# if have_library("fftw", "fftwnd_create_plan") -# srcs.push "na_fftw" -# else -# $defs.delete "-DHAVE_FFTW_H" -# end -#end - -$objs = srcs.map {|i| i+".o"} - -#dir_config("linux") -create_makefile("linux") diff --git a/externals/gridflow/devices4ruby/ioctl.rb b/externals/gridflow/devices4ruby/ioctl.rb deleted file mode 100644 index 100d138d..00000000 --- a/externals/gridflow/devices4ruby/ioctl.rb +++ /dev/null @@ -1,66 +0,0 @@ -# general-purpose code for performing -# less-than-trivial IOCTL operations. -# note that this is quite hackish -# but is still better than writing actual C code. - -module Linux; DEVICES_VERSION = "0.1.1"; end - -module IoctlClass - def ioctl_reader(sym,cmd_in) - module_eval %{def #{sym} - ioctl_intp_in(#{cmd_in}) - end} - end - def ioctl_writer(sym,cmd_out) - module_eval %{def #{sym}=(v) - ioctl_intp_out(#{cmd_out},v) - #{sym} if respond_to? :#{sym} - end} - end - def ioctl_accessor(sym,cmd_in,cmd_out) - ioctl_reader(sym,cmd_in) - ioctl_writer(sym,cmd_out) - end -end - -module Ioctl - # this method is not used anymore - def int_from_4(foo) - # if it crashes, just insert foo=foo.reverse here. - (foo[0]+0x100*foo[1])+0x10000*(foo[2]+0x100*foo[3]) - end - -# this was a big hack (from hell) that i used until I actually -# learned the other feature of ioctl(). -=begin - def ioctl_intp_out(arg1,arg2) - tmp = arg2 + 2**32 - foo = [2*tmp.id + 16].pack("l").unpack("P4")[0] - tmp_ptr = int_from_4(foo) -# STDOUT.printf "tmp_ptr=%x\n", tmp_ptr - ioctl(arg1,tmp_ptr) - end - - def ioctl_intp_in(arg1) - tmp = 0xdeadbeef + 2**32 - foo = [2*tmp.id + 16].pack("l").unpack("P4")[0] - tmp_ptr = int_from_4(foo) -# tmp_ptr = foo.unpack("l")[0] -# STDOUT.printf "tmp_ptr=%x\n", tmp_ptr - ioctl(arg1,tmp_ptr) - tmp & (2**32-1) - end -=end - - def ioctl_intp_out(arg1,arg2) - ioctl(arg1,[arg2].pack("l")) - end - - def ioctl_intp_in(arg1) - ioctl(arg1,s="blah") - return s.unpack("l")[0] - end - -end - -class IO; include Ioctl; end |