CX25840 module

If you use this driver. I urge you to donate $10 or more to the Asian 
earthquake and tsunamis victims through the Red Cross organization.

http://www.icrc.org/web/eng/siteeng0.nsf/iwpList2/Help_the_ICRC?OpenDocument
http://www.icrc.org/web/eng/siteeng0.nsf/html/F136DCCB5929912F41256DFE003F6B7C?OpenDocument&Style=Custo_Final.3&View=defaultBody3


This module provides support for the PVR150 and the PVR500 cards. 
The module is alpha state and to be considered under development.

Usage: (example with one 150 and one 500 card)
 insmod driver/cx25840.ko debug=1
 insmod driver/tuner.ko debug=1
 insmod driver/wm8775.ko debug=1
 insmod driver/ivtv.ko ivtv_std=2 tuner=51,52,52
 utils/ivtvctl -d /dev/video0 -u 1 -f width=720,height=576 -p 6
 utils/ivtvctl -d /dev/video1 -u 1 -f width=720,height=576 -p 7
 utils/ivtvctl -d /dev/video2 -u 1 -f width=720,height=576 -p 7
 utils/ivtvctl -d /dev/video0 -r $(((175188*16/1000))
 dd if=/dev/video0 of="150-0.mpeg" bs=1024 count=25K
 utils/ivtvctl -d /dev/video0 -r $(((182188*16/1000))
 dd if=/dev/video0 of="150-1.mpeg" bs=1024 count=25K
 utils/ivtvctl -d /dev/video1 -r $(((175188*16/1000))
 dd if=/dev/video1 of="501-0.mpeg" bs=1024 count=25K
 utils/ivtvctl -d /dev/video1 -r $(((182188*16/1000))
 dd if=/dev/video1 of="501-1.mpeg" bs=1024 count=25K
 utils/ivtvctl -d /dev/video2 -r $(((175188*16/1000))
 dd if=/dev/video2 of="502-0.mpeg" bs=1024 count=25K
 utils/ivtvctl -d /dev/video2 -r $(((182188*16/1000))
 dd if=/dev/video2 of="502-1.mpeg" bs=1024 count=25K

Inputs:
0 = s-video        (Not tested)
2 = composite
6 = tuner, pvr-150
7 = tuner, pvr-500

Tested and seemingly working:
 - PAL
 - tuner.
 - composite.
 - audio.

TODO:
 - Auto detection of cards and module loading.
 - Scaling and Cropping. Scaling code exists but doesn't work.
 - Auto update of cropping and scaling parameters on input change. 
   (needs an active thread??)
 - NTSC (might work already)
 - S-video (might work already)
 - VBI, no support at all currently.
 - Image properties settings, hue, contrasts etc.
 - Audio properties settings, EQ, balance, volume.
 - Shrink the register file by removing debug information (about 110K in 
   .o file).
 - Publish the auto generation scripts and source for the settings and 
   register files.
 - Find out why the magic WI2C(4, 0x43, 0x00,0x16,0x70,0x4a) is needed 
   for the tuner to work.

Tuners:
 Tuner types on different PVR150 and PVR500 cards.
  - PVR150(MCE) NTSC, seems to have a LG TAPC, type 47 tuner.
  - PVR150 PAL, has a Philips MQ1216ME/I tuner, only supported by the 
    patched tuner.ko module provided in this patch, type 52
  - PVR150MCE PAL, has a LG TAPE (not TAPC) tuner, only supported by 
    the patched tuner.ko module provided in this patch, type 51
  - PVR500, has two Philips MQ1216ME/I tuners only supported by the 
    patched tuner.ko module provided in this patch, type 51

  I've not managed to use any of tuner types provided in a 2.6.8 kernel.  

  I've copied and patched the tuner.c file to the driver directory of 
  ivtv and made it part of the build process, for my and others 
  convenience.  The patched tuner module has a type 51 and a type 52 as 
  indicated above.  They are NOT created from any specs, the only input 
  used are I2C scans from the corresponding XP driver. So the drivers 
  are probably not that good. :) I urged anyone with access to the 
  specs to review the code and submit it to the tuner.c maintainer. (or 
  provide me a copy of the specs)

  Note that the PVR500 cards have three tuners, two identical TV tuners
  and one radio tuner connected to the first 'PVR150' only.

  In order for the tuner to work I need to send the following 4 bytes to 
  I2C address 0x43 0x00,0x16,0x70,0x4a. I don't know which chip this is 
  and why it is needed. But it works, so I've kept it... Power control??

PVR500:
 This card seems to be two PVR150 cards on one card with some exceptions.
  - The broadcast audio is not connected to the same input on the 
    cx25804s, hence the need for a separate input for the 500 cards. 
    input 6 will be soundless.

  - Composite video and S-video seems only to be hooked up to the first 
    PVR150 instance.

Firmware:
  The firmware image HcwMakoA.ROM, can be found on the installation CD 
  for Winedos and is expected to be placed in /lib/modules

  The firmware is used for broadcast audio detection and decoding and 
  hence not needed for line-in audio.

  The syslog will report the MD5sum and SHA1 sum of the image upon 
  successful load. There seems to exists several versions of this 
  firmware.

 MD5, aa4d1e3dd17667957d8fe5b8d2d19395
 SHA1 60eafed58e943664aae4754b32271e09a95496b4
 is shipped with the PVR150 PAL.
 
Files:
 cx25840-driver.c   - Main driver file for the cx25840 chip.
 cx25840-settings.h - Definition of all cx25840 settings, used to create 
                      configuration sequences. Auto generated, don't edit
 cx25840-register.h - Register definitions file. Auto generated, don't edit.
 cx25840-register.c - Register constants file. (This file will be 
                      shrinked in future versions.) Auto generated, 
                      don't edit.
 cx25840.c          - old driver file, obsolete
 cx25840.h          - 
 wm8775.c .h        - Driver for the wm8775 audio digitizer chip, used 
                      for line-in audio.

Module options:
 i2c_enable=1,-1,-1,-1,-1,-1,-1,-1 
    The cx25480 must be disabled for PVR350 cards, and saa7127 support 
    must be disabled for PVR150/500 cards

    Count and check the order of the pvr150/500/350 cards, and then use 
    this module arg for each saa7127 and cx25840 module, to choose the 
    chip for each used.
 Example: (3 cards, 350,250,150 in that order...)
  options saa7127 i2c_enable=1,-1
  options cx25840 i2c_enable=-1,1

 Also sometimes it seems you may want to try and not specify i2c_enable for
 the cx25840 card like above, just the saa7127, or possibly just the cx25840,
 like this...
 options saa7127 i2c_enable=1,-1 
 or opposite of that... (no saa7127 line)
 options cx25840 i2c_enable=-1,1
