hardware
index
/usr/ports/multimedia/kbtv2-core/work/kbtv-2.0/Core/hardware.py

MODULE
    hardware -- classes for hardware setup
 
COPYRIGHT
    (c) 2005-2008, Danny Pansters <danny@ricin.com>
    All rights reserved. Dit werk is auteursrechtelijk beschermd.
 
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
 
    1. Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
 
    THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE
    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
DESCRIPTION
     This module contains classes for hardware setup and detection. The
     main class which uses all others is Setup.
 
CLASSES
    Chip
    HWPool
    Product
    Setup
 
CONSTANTS
    BKTR_PRODUCTS
    Bktr product matrix, dictionary {(vendor_id, product_id): 'desc'}.
    Here product_id is a fake id reflecting the bktr card number
 
    BACKENDS = ('bktr', 'cxm', 'saa', 'pwc')
    Backend modules for FreeBSD, only the bktr backend is guaranteed to be
    available (though maybe not functional if the device isn't set up
    properly yet). The others depend on build/install preferences.
 
    PWC_PRODUCTS
    Pwc product matrix, dictionary {(vendor_id, product_id): 'desc'}.
 
    CXM_PRODUCTS
    Cxm product matrix, dictionary {(vendor_id, product_id): 'desc'}.
 
    SAA_PRODUCTS
    Saa product matrix, dictionary {(vendor_id, product_id): 'desc'}.
    Though there are many cards listed it doesn't mean that they all work.
 
    TUNER_TYPES
    Tuner type dictionary {number: 'desc'}.
 
    BROADCAST_STANDARDS
    Broadcast standard dictionary {number: 'desc'}
 
    VIDEO_STANDARDS
    Video standard dictionary {number: 'desc'}
 
    AUDIO_STANDARDS
    Audio standard dictionary {number: 'desc'}
 
    WEBCAM_STANDARDS
    Webcam standard (sizes) dictionary {number: 'desc'}

 
Modules
       
util

 
Classes
       
__builtin__.list(__builtin__.object)
HWPool
Chip
Product
Setup

 
class Chip
    -> Chip
 
DESCRIPTION
    Class that describes a Chip object, which means the capture chip.
    Its attributes are id (corresponding with the device field in
    dev.xyz.0.%pnpinfo), and desc (corresponding with dev.xyz.0.%desc).
    You must supply a valid backend name ('bktr', 'cxm', or 'saa') and if 
    not 0 the backend instance number. There are no methods other than init.
    If id is set to '', the capture chip is not present (or backend not
    properly set up). Note that id is a string, though it represents a 
    hex value.
 
CONSTRUCTOR
    Chip(str backend, int backendnumber=0)
 
ATTRIBUTES
    str desc
    str id
    str vendor_desc
    str vendor_id
 
EXAMPLES
    c = Chip('bktr')
    c.id
    -> '0x0350'         # 848 in hex
    c.desc
    -> 'BrookTree 848A' # the 'A' is determined from id and revision #
    c.vendor_id
    -> '0x109e'
    c = Chip(d, 1)
    c.id
    -> ''
 
  Methods defined here:
__init__(self, backend, backendnumber=0)
-> Chip
 
DESCRIPTION
    Creates a Chip object, with attributes id and desc. If
    backend is not valid for TV or backendnumber not available,
    the id is set to ''.
 
EXAMPLES
    c = Chip('saa')
    c.id
    -> '0x7134'
    c.vendor_id
    -> '0x1131'
    c.desc
    -> 'Philips SAA7134 AV broadcast decoder'
    c = Chip('saa', 1)
    c.id
    -> ''

 
class HWPool(__builtin__.list)
    -> HWPool
 
DESCRIPTION
    Class that describes a hardware pool object, which resembles 
    util.DevicePool, but here it is not about the actual device nodes
    but backend instances, e.g. pwc0 or bktr1. It's a subclass of
    list and contains a list of Products. All real functionality is in 
    the method detect() which can be called multiple times.
 
CONSTRUCTOR
    HWPool()
 
METHODS
    bool detect()
 
EXAMPLES
    hw = HWPool()
    hw.detect()
    -> True
    len(hw)
    -> 3
    for item in hw:
        print (item.backend + str(item.backendnumber)), item.vendor_desc
    -> bktr0 Pinnacle Systems Inc
       saa0 AverMedia Technologies Inc
       pwc0 Logitech
 
 
Method resolution order:
HWPool
__builtin__.list
__builtin__.object

Methods defined here:
__init__(self)
-> HWPool
 
DESCRIPTION
    Creates an empty HWPool list object.
 
EXAMPLES
    hw = HWPool()
    len(hw)
    -> 0
detect(self)
-> bool
 
DESCRIPTION
    Detects hardware for all availablebackend instances. For 
    every backend in BACKENDS backend instances are looked up, and 
    hardware information is gathered and stored in Product objects.
    Returns True on succes, False if nothing found.
 
EXAMPLES
    hw = HWPool()
    hw.detect()
    -> True
    hw[0].backend
    -> 'bktr'

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from __builtin__.list:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__delitem__(...)
x.__delitem__(y) <==> del x[y]
__delslice__(...)
x.__delslice__(i, j) <==> del x[i:j]
 
Use of negative indices is not supported.
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iadd__(...)
x.__iadd__(y) <==> x+=y
__imul__(...)
x.__imul__(y) <==> x*=y
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__repr__(...)
x.__repr__() <==> repr(x)
__reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
__rmul__(...)
x.__rmul__(n) <==> n*x
__setitem__(...)
x.__setitem__(i, y) <==> x[i]=y
__setslice__(...)
x.__setslice__(i, j, y) <==> x[i:j]=y
 
Use  of negative indices is not supported.
append(...)
L.append(object) -- append object to end
count(...)
L.count(value) -> integer -- return number of occurrences of value
extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
insert(...)
L.insert(index, object) -- insert object before index
pop(...)
L.pop([index]) -> item -- remove and return item at index (default last)
remove(...)
L.remove(value) -- remove first occurrence of value
reverse(...)
L.reverse() -- reverse *IN PLACE*
sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1

Data and other attributes inherited from __builtin__.list:
__new__ = <built-in method __new__ of type object at 0x8109360>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class Product
    -> Product
 
DESCRIPTION
    Class that describes a Product object, representing a piece of
    hardware. Its attributes are vendor_id, product_id, and the 
    corresponding descriptive strings vendor_desc and product_desc.
    You must supply a valid backend name ('bktr' or 'saa' or 'pwc') and 
    if not 0 the backend instance number. There are no methods other than 
    init. For bktr, pseudo-product IDs are used (from backend output).
 
CONSTRUCTOR
    Product(str backend, int backendnumber=0)
 
ATTRIBUTES
    str product_desc
    str product_id
    str vendor_desc
    str vendor_id
    str backend
    int backendnumber
 
EXAMPLES
    p = Product('pwc', 0)
    print p.vendor_id, p.vendor_desc
    print p.product_id, p.product_desc
    -> 0x046d Logitech
       0x08b5 Logitech QuickCam Orbit/Sphere (old model)
 
  Methods defined here:
__init__(self, backend, backendnumber=0)
-> Product
 
DESCRIPTION
    Creates a Product object.
 
EXAMPLES
    p = Product('saa')
    p.vendor_id
    -> '0x1461'
    p.product_desc
    -> 'AverMedia M156/Medion 2819'

 
class Setup
    -> Setup
 
DESCRIPTION
    Class to set up hardware and add users to the operator group.
 
CONSTRUCTOR
    Setup()
 
ATTRIBUTES
    list klds
    bool bktr_in_kernel
    util.DevicePool devicepool
    hardware.HWPool hwpool
    list users
    list errors
 
METHODS
    bool setup()
    bool addUser(str username)
 
EXAMPLES
    setup = Setup()
    setup.bktr_in_kernel
    -> False
    setup.klds
    -> ['bktr', 'saa', 'pwc']
    setup.setup()
    -> True
    for item in setup.hwpool:
        print (item.backend + str(item.backendnumber)), item.vendor_desc
    -> bktr0 Pinnacle Systems Inc
       saa0 AverMedia Technologies Inc
       pwc0 Logitech
    setup.devicepool.config()
    -> [('bktr0', 'root:operator', '0660'),
        ('tuner0', 'root:operator', '0660'),
        ('saa0', 'root:operator', '0660'),
        ('sau0', 'root:operator', '0660'),
        ('iic0', 'root:operator', '0660'),
        ('video0', root:operator', '0660')]
    setup.addUser('danny')
    setup.users
    -> ['root', 'danny']
 
  Methods defined here:
__init__(self)
addUser(self, username)
-> bool
 
Returns True if username was succesfully added to the operator group.
setup(self)
-> bool
 
Returns True if available klds could be (re)loaded and devices
set up with the desired permissions (operator group can read/write).

 
Data
        AUDIO_STANDARDS = {0: 'FM-Mono/NICAM', 1: 'FM-Stereo (A2, D/K1)'}
BACKENDS = ('bktr', 'cxm', 'saa', 'pwc')
BKTR_PRODUCTS = {('0x0070', '0xff02'): 'Hauppauge WinCast/TV', ('0x1033', '0xff08'): 'NEC PK-UG-X017', ('0x107d', '0xff0f'): 'Leadtek Winfast TV 2000', ('0x10b4', '0xff03'): 'STB TV/PCI', ('0x10e0', '0xff05'): 'IMS TV Turbo', ('0x10fc', '0xff09'): 'I/O DATA GV-BCTV2/PCI', ('0x10fc', '0xff11'): 'I/O DATA GV-BCTV3/PCI', ('0x11bd', '0xff01'): 'Pinnacle/Miro TV', ('0x11bd', '0xff13'): 'Pinnacle PCTV Rave', ('0x12cd', '0xff0d'): 'Video Highway Xtreme', ...}
BROADCAST_STANDARDS = {0: 'PAL B/G', 1: 'PAL D/K', 2: 'PAL I', 3: 'PAL L', 4: "PAL L'", 5: 'NTSC', 6: 'NTSC Japan'}
CXM_PRODUCTS = {('0x0070', '0x4000'): 'Hauppauge WinTV PVR-350', ('0x0070', '0x4001'): 'Hauppauge WinTV PVR-250 (v1)', ('0x0070', '0x4009'): 'Hauppauge WinTV PVR-250', ('0x0070', '0x4801'): 'Hauppauge WinTV PVR-250 MCE', ('0x0070', '0x8800'): 'Hauppauge WinTV PVR-150/500', ('0x0070', '0x8801'): 'Hauppauge WinTV PVR-150/500', ('0x0070', '0x8803'): 'Hauppauge WinTV PVR-150/500', ('0x0070', '0x8804'): 'Hauppauge WinTV PVR-150/500', ('0x0070', '0x8811'): 'Hauppauge WinTV PVR-150/500', ('0xff00', '0xff00'): 'Unknown card'}
PWC_PRODUCTS = {('0x041e', '0x400c'): 'Creative Labs Webcam 5 (old model)', ('0x041e', '0x4011'): 'Creative Labs Webcam Pro Ex', ('0x046d', '0x08b0'): 'Logitech QuickCam Pro 3000', ('0x046d', '0x08b1'): 'Logitech QuickCam Notebook Pro (old model)', ('0x046d', '0x08b2'): 'Logitech QuickCam Pro 4000', ('0x046d', '0x08b3'): 'Logitech QuickCam Zoom', ('0x046d', '0x08b4'): 'Logitech QuickCam Zoom (new model)', ('0x046d', '0x08b5'): 'Logitech QuickCam Orbit/Sphere (old model)', ('0x046d', '0x08b6'): 'Logitech QuickCam (reserved ID)', ('0x046d', '0x08b7'): 'Logitech QuickCam (reserved ID)', ...}
SAA_PRODUCTS = {('0x0000', '0x4091'): 'Beholder BeholdTV 409 FM', ('0x1019', '0x4cb4'): 'Elitegroup ECS TVP3XP FM1216 Tuner', ('0x1019', '0x4cb5'): 'Elitegroup ECS TVP3XP FM1236 Tuner (NTSC, FM)', ('0x102b', '0x48d0'): 'Matrox CronosPlus', ('0x1043', '0x0210'): 'FlyTV mini Asus Digimatrix/Digimatrix TV', ('0x1043', '0x4840'): 'ASUS TV-FM 7134', ('0x1043', '0x4842'): 'TV-FM 7134', ('0x1043', '0x4843'): 'ASUS TV-FM 7133', ('0x1043', '0x4845'): 'TV-FM 7135', ('0x1043', '0x4862'): 'P7131 Dual', ...}
TUNER_TYPES = {0: 'None', 1: 'Philips', 2: 'Philips MK3', 3: 'Temic', 4: 'Alps', 5: 'LG', 6: 'Microtune'}
VENDORS = {'0x0000': 'Beholder', '0x0070': 'Hauppauge Computer Works Inc', '0x0270': 'Hauppauge Computer Works Inc', '0x041e': 'Creative Labs', '0x046d': 'Logitech', '0x0471': 'Philips Semiconductors', '0x04cc': 'Sotec', '0x055d': 'Samsung', '0x069a': 'Askey Computer Corp', '0x06be': 'AME Co', ...}
VIDEO_STANDARDS = {0: 'AUTO', 1: 'NTSC', 2: 'NTSC-J', 3: 'PAL', 4: 'PAL-M', 5: 'PAL-N', 6: 'SECAM'}
WEBCAM_STANDARDS = {0: 'SQCIF', 1: 'QSIF', 2: 'QCIF', 3: 'SIF', 4: 'CIF', 5: '4SIF', 6: '4CIF'}