diff --git a/.gitignore b/.gitignore
index f4efc68..646fdf6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,22 +1,22 @@
-# Empty extraction directories
-docs/diseqc/images/
-
-# Third-party dependencies
-firmware/fx2lib/
-
-# Build artifacts
-firmware/build/
-tools/__pycache__/
-
-# TUI
-tui/.venv/
-tui/__pycache__/
-
-# MCP server
-mcp/skywalker-mcp/.venv/
-mcp/skywalker-mcp/__pycache__/
-
-# Documentation site
-site/node_modules/
-site/dist/
-site/.astro/
+# Empty extraction directories
+docs/diseqc/images/
+
+# Third-party dependencies
+firmware/fx2lib/
+
+# Build artifacts
+firmware/build/
+tools/__pycache__/
+
+# TUI
+tui/.venv/
+tui/__pycache__/
+
+# MCP server
+mcp/skywalker-mcp/.venv/
+mcp/skywalker-mcp/__pycache__/
+
+# Documentation site
+site/node_modules/
+site/dist/
+site/.astro/
diff --git a/README.md b/README.md
index 23b246e..d970995 100644
--- a/README.md
+++ b/README.md
@@ -1,179 +1,179 @@
-
-
-# SkyWalker-1
-
-**Reverse-engineered documentation, custom firmware, and Python tooling for the Genpix SkyWalker-1 DVB-S USB 2.0 satellite receiver.**
-
-[](https://skywalker-1.warehack.ing)
-[](https://skywalker-1.warehack.ing/firmware/custom-v301/)
-[](#license)
-
-
-
----
-
-The SkyWalker-1 is a standalone USB 2.0 DVB-S receiver built around a **Cypress FX2LP** (CY7C68013A) microcontroller and **Broadcom BCM4500** satellite demodulator. It was designed by [Genpix Electronics](https://www.genpix-electronics.com/index.php?act=viewDoc&docId=9) for DVB-S, Turbo-coded, Digicipher II, and DSS reception.
-
-This project documents the device's complete internal architecture -- every vendor command, register, GPIO pin, and data path -- built up from Linux kernel driver analysis, Ghidra firmware disassembly of five firmware images, Windows BDA driver source review, and original custom firmware development.
-
-**[Browse the full documentation at skywalker-1.warehack.ing](https://skywalker-1.warehack.ing)**
-
-## What's Here
-
-```
-skywalker-1/
- firmware/ Custom FX2 firmware (SDCC + fx2lib, 1441 lines of C)
- skywalker1.c Full replacement firmware with 10 custom vendor commands
- Makefile Build rules targeting CY7C68013A
- dscr.a51 USB descriptors (VID 0x09C0, PID 0x0203)
- firmware-dump/ Extracted stock firmware binaries (v2.06, v2.10, v2.13 x3)
- firmware-driver/ Genpix Windows BDA driver source (reference material)
- tools/ Python utilities for direct hardware interaction
- skywalker.py Multi-mode RF tool: spectrum, scan, monitor, lband, track
- skywalker_lib.py Shared library: USB transport, BCM4500 register access
- fw_load.py FX2 RAM firmware loader via 0xA0 vendor request
- tune.py Transponder tuner with lock detection and BER readout
- ts_analyze.py MPEG-2 transport stream parser and PID analyzer
- eeprom_dump.py Full EEPROM image extraction
- eeprom_write.py EEPROM flash tool with C2 format support
- wine_memdump.py Extract firmware from Genpix Windows updater EXEs
- test_*.py Boot sequence and I2C debug/isolation harnesses
- site/ Astro Starlight documentation (37 pages, 9 sections)
- docs/ Raw analysis documents and master hardware reference
-```
-
-## Hardware at a Glance
-
-| | |
-|---|---|
-| **MCU** | Cypress CY7C68013A (FX2LP) -- 8051 core at 48 MHz, USB 2.0 Hi-Speed |
-| **Demodulator** | Broadcom BCM4500 -- DVB-S / Turbo / DCII / DSS, 128-pin MQFP |
-| **IF Range** | 950 -- 2150 MHz |
-| **Symbol Rate** | 256 Ksps -- 30 Msps |
-| **LNB Control** | 13/18V, 22 kHz tone, DiSEqC 1.0/1.2, legacy switches |
-| **Connector** | IEC F-type female |
-| **Transport** | 8-bit parallel bus via GPIF into USB bulk endpoint EP2 |
-
-```
- +--[ I2C EEPROM 0x51 ]
- |
-USB 2.0 HS | I2C Bus (400 kHz)
-Host PC <----> [ CY7C68013A FX2LP ] <-----> [ BCM4500 Demod 0x08 ]
- | 8051 @ 48 MHz | |
- | GPIF Engine |<-----------+ 8-bit parallel TS
- | EP2 Bulk IN |
- | GPIO (P0/P3) |---> [ 22 kHz Osc ] ---> LNB/Coax
- | |---> [ LNB Voltage Ctrl ]
- +-----------------+
- |
- +--[ Tuner/LNB IC 0x10 ]
-```
-
-**Supported modulations:** DVB-S (QPSK), DVB-S (BPSK), Turbo QPSK, Turbo 8PSK, Turbo 16QAM, Digicipher II (Combo, Split I/Q, Offset QPSK), DSS (QPSK).
-
-> DVB-S2 is **not supported**. The BCM4500 predates DVB-S2 and contains no LDPC or BCH decoder hardware. This is a silicon limitation -- no firmware update can change it. See the [DVB-S2 investigation](https://skywalker-1.warehack.ing/driver/dvb-s2/).
-
-## Custom Firmware
-
-The stock EEPROM firmware was replaced with an open-source implementation built from scratch using **SDCC** and **fx2lib**. It implements all stock vendor commands (kernel driver compatible) plus 10 new diagnostic and analysis commands:
-
-| Command | ID | Purpose |
-|---------|-----|---------|
-| Spectrum Sweep | `0xB0` | AGC-based power sweep across IF range |
-| Raw Demod Read | `0xB1` | Direct BCM4500 indirect register read |
-| Raw Demod Write | `0xB2` | Direct BCM4500 indirect register write |
-| Blind Scan | `0xB3` | Carrier detection at arbitrary frequency |
-| Signal Monitor | `0xB7` | Combined SNR + AGC + lock in single transfer |
-| Tune Monitor | `0xB8` | Tune + dwell + measure in one round-trip |
-| Multi Reg Read | `0xB9` | Batch read of contiguous indirect registers |
-
-Build and load:
-
-```bash
-cd firmware
-make # requires SDCC + fx2lib
-make load # RAM-loads via fw_load.py (does not touch EEPROM)
-```
-
-## Python Tools
-
-All tools communicate directly with the SkyWalker-1 over USB using `pyusb`. No kernel driver required.
-
-```bash
-# Load custom firmware into FX2 RAM
-python tools/fw_load.py firmware/build/skywalker1.bix
-
-# Tune to a transponder and check lock
-python tools/tune.py --freq 12224 --sr 20000 --pol H --mod dvb-s
-
-# Sweep the IF band and render ASCII spectrum
-python tools/skywalker.py spectrum --start 950 --stop 2150 --step 5
-
-# Real-time signal strength (dish alignment)
-python tools/skywalker.py monitor --freq 1175
-
-# Dump full EEPROM contents
-python tools/eeprom_dump.py --output eeprom.bin
-```
-
-The `skywalker.py` multi-mode tool provides five operating modes: `spectrum` (sweep analyzer), `scan` (transponder finder), `monitor` (signal strength meter), `lband` (direct L-band input), and `track` (carrier/beacon tracker with CSV logging).
-
-## Documentation Site
-
-The full documentation is published at **[skywalker-1.warehack.ing](https://skywalker-1.warehack.ing)** and covers:
-
-| Section | Pages | Covers |
-|---------|-------|--------|
-| **Hardware** | 4 | Board architecture, GPIO pin map, RF specifications |
-| **USB Interface** | 4 | 30 vendor commands, boot sequence, endpoint layout |
-| **BCM4500** | 5 | Register map, indirect access protocol, tuning sequence, GPIF streaming, signal monitoring |
-| **LNB & DiSEqC** | 3 | Voltage/tone control, DiSEqC 1.0/1.2, legacy Dish switches |
-| **I2C Bus** | 2 | Bus architecture, STOP corruption bug root cause analysis |
-| **Firmware** | 7 | 5 stock versions compared, custom v3.01 and v3.02, storage formats |
-| **Driver** | 2 | Linux gp8psk kernel driver, DVB-S2 incompatibility investigation |
-| **Tools** | 7 | Every Python utility documented with usage examples |
-| **Reference** | 1 | Consolidated master reference (registers, commands, GPIO, I2C) |
-
-To run the docs site locally:
-
-```bash
-cd site
-npm install
-npm run dev # http://localhost:4321
-```
-
-
-Docker deployment
-
-The docs site includes a multi-stage Dockerfile with dev and prod targets. Production serves static files through Caddy.
-
-```bash
-cd site
-
-# Development (HMR via volume mounts)
-APP_ENV=dev docker compose up --build
-
-# Production (static build served by Caddy)
-APP_ENV=prod docker compose up --build -d
-```
-
-
-
-## Project History
-
-This project started with USB packet captures and `lsusb` output, then progressed through increasingly deep layers of the hardware:
-
-1. **EEPROM extraction** -- dumped raw firmware bytes over I2C
-2. **Ghidra disassembly** -- decompiled five 8051 firmware images, mapped all functions and vendor commands
-3. **Windows driver analysis** -- cross-referenced Ghidra findings against Genpix BDA driver source
-4. **Linux driver analysis** -- mapped kernel `gp8psk` driver to decoded vendor commands
-5. **Custom firmware** -- wrote a full replacement in C, discovered and fixed the [I2C STOP corruption bug](https://skywalker-1.warehack.ing/i2c/stop-corruption-bug/)
-6. **RF tooling** -- built spectrum analyzer, blind scanner, and signal monitor on top of the custom command set
-
-## Contributing
-
-This is a niche reverse-engineering project for a specific piece of satellite hardware. If you have a SkyWalker-1 (or other Genpix device using the BCM4500), contributions are welcome -- particularly additional firmware dumps, register documentation, or corrections to the analysis.
-
-## License
-
-The custom firmware source, Python tools, and documentation are open source. Stock firmware binaries in `firmware-dump/` are proprietary Genpix Electronics images retained for research and interoperability purposes.
+
+
+# SkyWalker-1
+
+**Reverse-engineered documentation, custom firmware, and Python tooling for the Genpix SkyWalker-1 DVB-S USB 2.0 satellite receiver.**
+
+[](https://skywalker-1.warehack.ing)
+[](https://skywalker-1.warehack.ing/firmware/custom-v301/)
+[](#license)
+
+
+
+---
+
+The SkyWalker-1 is a standalone USB 2.0 DVB-S receiver built around a **Cypress FX2LP** (CY7C68013A) microcontroller and **Broadcom BCM4500** satellite demodulator. It was designed by [Genpix Electronics](https://www.genpix-electronics.com/index.php?act=viewDoc&docId=9) for DVB-S, Turbo-coded, Digicipher II, and DSS reception.
+
+This project documents the device's complete internal architecture -- every vendor command, register, GPIO pin, and data path -- built up from Linux kernel driver analysis, Ghidra firmware disassembly of five firmware images, Windows BDA driver source review, and original custom firmware development.
+
+**[Browse the full documentation at skywalker-1.warehack.ing](https://skywalker-1.warehack.ing)**
+
+## What's Here
+
+```
+skywalker-1/
+ firmware/ Custom FX2 firmware (SDCC + fx2lib, 1441 lines of C)
+ skywalker1.c Full replacement firmware with 10 custom vendor commands
+ Makefile Build rules targeting CY7C68013A
+ dscr.a51 USB descriptors (VID 0x09C0, PID 0x0203)
+ firmware-dump/ Extracted stock firmware binaries (v2.06, v2.10, v2.13 x3)
+ firmware-driver/ Genpix Windows BDA driver source (reference material)
+ tools/ Python utilities for direct hardware interaction
+ skywalker.py Multi-mode RF tool: spectrum, scan, monitor, lband, track
+ skywalker_lib.py Shared library: USB transport, BCM4500 register access
+ fw_load.py FX2 RAM firmware loader via 0xA0 vendor request
+ tune.py Transponder tuner with lock detection and BER readout
+ ts_analyze.py MPEG-2 transport stream parser and PID analyzer
+ eeprom_dump.py Full EEPROM image extraction
+ eeprom_write.py EEPROM flash tool with C2 format support
+ wine_memdump.py Extract firmware from Genpix Windows updater EXEs
+ test_*.py Boot sequence and I2C debug/isolation harnesses
+ site/ Astro Starlight documentation (37 pages, 9 sections)
+ docs/ Raw analysis documents and master hardware reference
+```
+
+## Hardware at a Glance
+
+| | |
+|---|---|
+| **MCU** | Cypress CY7C68013A (FX2LP) -- 8051 core at 48 MHz, USB 2.0 Hi-Speed |
+| **Demodulator** | Broadcom BCM4500 -- DVB-S / Turbo / DCII / DSS, 128-pin MQFP |
+| **IF Range** | 950 -- 2150 MHz |
+| **Symbol Rate** | 256 Ksps -- 30 Msps |
+| **LNB Control** | 13/18V, 22 kHz tone, DiSEqC 1.0/1.2, legacy switches |
+| **Connector** | IEC F-type female |
+| **Transport** | 8-bit parallel bus via GPIF into USB bulk endpoint EP2 |
+
+```
+ +--[ I2C EEPROM 0x51 ]
+ |
+USB 2.0 HS | I2C Bus (400 kHz)
+Host PC <----> [ CY7C68013A FX2LP ] <-----> [ BCM4500 Demod 0x08 ]
+ | 8051 @ 48 MHz | |
+ | GPIF Engine |<-----------+ 8-bit parallel TS
+ | EP2 Bulk IN |
+ | GPIO (P0/P3) |---> [ 22 kHz Osc ] ---> LNB/Coax
+ | |---> [ LNB Voltage Ctrl ]
+ +-----------------+
+ |
+ +--[ Tuner/LNB IC 0x10 ]
+```
+
+**Supported modulations:** DVB-S (QPSK), DVB-S (BPSK), Turbo QPSK, Turbo 8PSK, Turbo 16QAM, Digicipher II (Combo, Split I/Q, Offset QPSK), DSS (QPSK).
+
+> DVB-S2 is **not supported**. The BCM4500 predates DVB-S2 and contains no LDPC or BCH decoder hardware. This is a silicon limitation -- no firmware update can change it. See the [DVB-S2 investigation](https://skywalker-1.warehack.ing/driver/dvb-s2/).
+
+## Custom Firmware
+
+The stock EEPROM firmware was replaced with an open-source implementation built from scratch using **SDCC** and **fx2lib**. It implements all stock vendor commands (kernel driver compatible) plus 10 new diagnostic and analysis commands:
+
+| Command | ID | Purpose |
+|---------|-----|---------|
+| Spectrum Sweep | `0xB0` | AGC-based power sweep across IF range |
+| Raw Demod Read | `0xB1` | Direct BCM4500 indirect register read |
+| Raw Demod Write | `0xB2` | Direct BCM4500 indirect register write |
+| Blind Scan | `0xB3` | Carrier detection at arbitrary frequency |
+| Signal Monitor | `0xB7` | Combined SNR + AGC + lock in single transfer |
+| Tune Monitor | `0xB8` | Tune + dwell + measure in one round-trip |
+| Multi Reg Read | `0xB9` | Batch read of contiguous indirect registers |
+
+Build and load:
+
+```bash
+cd firmware
+make # requires SDCC + fx2lib
+make load # RAM-loads via fw_load.py (does not touch EEPROM)
+```
+
+## Python Tools
+
+All tools communicate directly with the SkyWalker-1 over USB using `pyusb`. No kernel driver required.
+
+```bash
+# Load custom firmware into FX2 RAM
+python tools/fw_load.py firmware/build/skywalker1.bix
+
+# Tune to a transponder and check lock
+python tools/tune.py --freq 12224 --sr 20000 --pol H --mod dvb-s
+
+# Sweep the IF band and render ASCII spectrum
+python tools/skywalker.py spectrum --start 950 --stop 2150 --step 5
+
+# Real-time signal strength (dish alignment)
+python tools/skywalker.py monitor --freq 1175
+
+# Dump full EEPROM contents
+python tools/eeprom_dump.py --output eeprom.bin
+```
+
+The `skywalker.py` multi-mode tool provides five operating modes: `spectrum` (sweep analyzer), `scan` (transponder finder), `monitor` (signal strength meter), `lband` (direct L-band input), and `track` (carrier/beacon tracker with CSV logging).
+
+## Documentation Site
+
+The full documentation is published at **[skywalker-1.warehack.ing](https://skywalker-1.warehack.ing)** and covers:
+
+| Section | Pages | Covers |
+|---------|-------|--------|
+| **Hardware** | 4 | Board architecture, GPIO pin map, RF specifications |
+| **USB Interface** | 4 | 30 vendor commands, boot sequence, endpoint layout |
+| **BCM4500** | 5 | Register map, indirect access protocol, tuning sequence, GPIF streaming, signal monitoring |
+| **LNB & DiSEqC** | 3 | Voltage/tone control, DiSEqC 1.0/1.2, legacy Dish switches |
+| **I2C Bus** | 2 | Bus architecture, STOP corruption bug root cause analysis |
+| **Firmware** | 7 | 5 stock versions compared, custom v3.01 and v3.02, storage formats |
+| **Driver** | 2 | Linux gp8psk kernel driver, DVB-S2 incompatibility investigation |
+| **Tools** | 7 | Every Python utility documented with usage examples |
+| **Reference** | 1 | Consolidated master reference (registers, commands, GPIO, I2C) |
+
+To run the docs site locally:
+
+```bash
+cd site
+npm install
+npm run dev # http://localhost:4321
+```
+
+
+Docker deployment
+
+The docs site includes a multi-stage Dockerfile with dev and prod targets. Production serves static files through Caddy.
+
+```bash
+cd site
+
+# Development (HMR via volume mounts)
+APP_ENV=dev docker compose up --build
+
+# Production (static build served by Caddy)
+APP_ENV=prod docker compose up --build -d
+```
+
+
+
+## Project History
+
+This project started with USB packet captures and `lsusb` output, then progressed through increasingly deep layers of the hardware:
+
+1. **EEPROM extraction** -- dumped raw firmware bytes over I2C
+2. **Ghidra disassembly** -- decompiled five 8051 firmware images, mapped all functions and vendor commands
+3. **Windows driver analysis** -- cross-referenced Ghidra findings against Genpix BDA driver source
+4. **Linux driver analysis** -- mapped kernel `gp8psk` driver to decoded vendor commands
+5. **Custom firmware** -- wrote a full replacement in C, discovered and fixed the [I2C STOP corruption bug](https://skywalker-1.warehack.ing/i2c/stop-corruption-bug/)
+6. **RF tooling** -- built spectrum analyzer, blind scanner, and signal monitor on top of the custom command set
+
+## Contributing
+
+This is a niche reverse-engineering project for a specific piece of satellite hardware. If you have a SkyWalker-1 (or other Genpix device using the BCM4500), contributions are welcome -- particularly additional firmware dumps, register documentation, or corrections to the analysis.
+
+## License
+
+The custom firmware source, Python tools, and documentation are open source. Stock firmware binaries in `firmware-dump/` are proprietary Genpix Electronics images retained for research and interoperability purposes.
diff --git a/docs/boot-debug-findings.md b/docs/boot-debug-findings.md
index 713898d..a30943e 100644
--- a/docs/boot-debug-findings.md
+++ b/docs/boot-debug-findings.md
@@ -1,257 +1,257 @@
-# BOOT_8PSK Debugging Findings
-
-Technical reference for the BCM4500 demodulator boot sequence on the Genpix SkyWalker-1 (Cypress FX2 CY7C68013A + Broadcom BCM4500), firmware v3.01.0. Documents the root cause analysis of a firmware hang during I2C initialization and the fixes applied.
-
-**Hardware:** Genpix SkyWalker-1 USB 2.0 DVB-S receiver
-**MCU:** Cypress CY7C68013A (FX2LP), 8051 core at 48MHz
-**Demodulator:** Broadcom BCM4500
-**Firmware:** Custom v3.01.0 (SDCC + fx2lib)
-**I2C bus speed:** 400kHz
-
----
-
-## The Problem
-
-Custom firmware v3.01.0 implements vendor command `BOOT_8PSK` (bRequest=0x89, wValue=1), which powers on the BCM4500 demodulator and initializes it via I2C. When first tested, this command caused the FX2 firmware to hang for over 10 seconds, making the USB device completely unresponsive -- no vendor command would return, and the host-side USB stack would report timeout errors.
-
-The initial suspicion was infinite I2C loops. The fx2lib I2C library uses bare `while` loops that poll hardware status bits with no timeout:
-
-```c
-// fx2lib/lib/i2c.c -- original code
-while ( !(I2CS & bmDONE) && !cancel_i2c_trans);
-```
-
-The `cancel_i2c_trans` variable is intended as an external abort mechanism, but nothing in the firmware sets it during normal operation. If the I2C controller never asserts `bmDONE` (for example, because a slave is holding SCL low), the firmware spins indefinitely in this loop.
-
-Adding I2C timeout protection (described below) eliminated the infinite-hang symptom, but the boot sequence still failed: the BCM4500 probe read returned NACK, and all three register initialization blocks failed.
-
-## Root Cause: Spurious I2C STOP Condition
-
-The boot function originally included a so-called "I2C bus reset" step before any I2C communication:
-
-```c
-I2CS |= bmSTOP;
-i2c_wait_stop();
-```
-
-This pattern appears in various FX2 example code and seems reasonable on its face -- send a STOP condition to ensure the I2C bus is in a known idle state before starting fresh. On the FX2's I2C controller hardware, this is incorrect.
-
-### Incremental Debug Modes
-
-The root cause was discovered through a series of incremental debug modes added to the `BOOT_8PSK` vendor command handler. Each mode executes a subset of the full boot sequence, isolating which step introduces the failure:
-
-| wValue | Action | Result |
-|--------|--------|--------|
-| `0x80` | No-op: return `config_status` and `boot_stage` only | Works |
-| `0x81` | GPIO + power + delays only (no I2C at all) | Works |
-| `0x82` | GPIO + power + `bmSTOP` + I2C probe read | **Fails** |
-| `0x83` | GPIO + power + `bmSTOP` + probe + init block 0 | **Fails** (same root cause) |
-| `0x84` | `bcm_direct_read` only (no GPIO, chip already powered) | Works |
-| `0x85` | GPIO + power + reset, **no** `bmSTOP`, then probe | Works |
-
-Three observations clinch the diagnosis:
-
-1. **Mode 0x82 fails but mode 0x85 succeeds.** These two modes are identical except that 0x82 issues `I2CS |= bmSTOP` before the probe read and 0x85 does not. The `bmSTOP` is the only difference, and it is the only thing that breaks I2C.
-
-2. **Mode 0x84 succeeds immediately after 0x82 fails.** Mode 0x84 calls `bcm_direct_read` with no GPIO manipulation or bus reset -- just a plain I2C combined read. If called after a failed 0x82, it succeeds. This proves two things: the BCM4500 is alive and responding on I2C, and the `i2c_combined_read` function itself is correct. The failure in 0x82 is not a timing or power issue.
-
-3. **Raw I2C reads via vendor command 0xB5 succeed after 0x82 fails.** Command 0xB5 uses the same `i2c_combined_read` function as `bcm_direct_read`. Running it from the host side after a failed 0x82 returns valid data from the BCM4500. This confirms the chip was alive the whole time -- the FX2's I2C controller was in a bad state, not the bus or the slave.
-
-The test scripts that drove this investigation are in the `tools/` directory:
-
-- `test_boot_debug.py` -- sends debug modes 0x80 through 0x83 sequentially
-- `test_i2c_debug.py` -- powers on via 0x81, runs bus scans, tests probe timing
-- `test_i2c_isolate.py` -- tests whether re-reset or insufficient delay causes failure
-- `test_i2c_pinpoint.py` -- the definitive test: compares 0x84, 0x85, and 0x82
-
-### What Happens Inside the FX2 I2C Controller
-
-The FX2's I2C master controller is a hardware peripheral accessed through the `I2CS`, `I2DAT`, and `I2CTL` SFRs. The controller implements an I2C state machine in silicon. Writing `bmSTOP` to `I2CS` instructs the hardware to generate a STOP condition (SDA rising while SCL is high).
-
-When no I2C transaction is active -- no prior START has been issued, and the bus is idle -- writing `bmSTOP` puts the controller into an inconsistent internal state. The `bmSTOP` bit may not clear properly (it is supposed to self-clear when the STOP condition completes on the bus), and subsequent START conditions fail to generate proper clock sequences or detect ACK from slaves.
-
-The Cypress TRM (EZ-USB Technical Reference Manual) does not explicitly warn against this, but the I2C chapter describes STOP as a step that follows a completed read or write transaction. It is not documented as a standalone bus-reset mechanism.
-
-The correct way to ensure a clean I2C bus state on the FX2 is to simply proceed with a new START condition. If the bus is idle (which it will be after power-on or after the previous transaction completed normally), the START succeeds and the controller enters its normal operating state. The hardware handles bus arbitration automatically on START.
-
-## The Fix
-
-The fix is a single deletion. Remove the spurious STOP from the boot sequence:
-
-```c
-/* BEFORE (broken): */
-I2CS |= bmSTOP;
-i2c_wait_stop();
-
-/* AFTER (correct): */
-/* NOTE: Do NOT send I2CS bmSTOP here. Sending STOP when no transaction
- * is active corrupts the FX2 I2C controller state, causing subsequent
- * START+ACK detection to fail. The I2C bus will be in a clean state
- * when we reach the probe step -- any prior transaction ended with STOP. */
-```
-
-The corrected `bcm4500_boot()` function proceeds directly from GPIO/power setup to the I2C probe read without any bus-reset step:
-
-```c
-static BOOL bcm4500_boot(void) {
- boot_stage = 1;
- cancel_i2c_trans = FALSE;
-
- /* P3.7, P3.6, P3.5 HIGH (idle state for control lines) */
- IOD |= 0xE0;
-
- /* Assert BCM4500 hardware RESET (P0.5 LOW) */
- OEA |= PIN_BCM_RESET;
- IOA &= ~PIN_BCM_RESET;
-
- /* No I2CS bmSTOP here -- see note above */
-
- /* Power on: P0.1 HIGH (enable), P0.2 LOW (disable off) */
- OEA |= (PIN_PWR_EN | PIN_PWR_DIS);
- IOA = (IOA & ~PIN_PWR_DIS) | PIN_PWR_EN;
-
- boot_stage = 2;
- delay(30); /* power settle */
-
- IOA |= PIN_BCM_RESET; /* release reset */
- delay(50); /* BCM4500 POR + mask ROM boot */
-
- boot_stage = 3;
- /* I2C probe -- if this fails, the chip didn't come out of reset */
- if (!bcm_direct_read(BCM_REG_STATUS, &i2c_rd[0]))
- return FALSE;
-
- /* ... register init blocks follow ... */
-}
-```
-
-## I2C Timeout Protection
-
-Even with the `bmSTOP` fix, timeout protection on all I2C operations is essential. The FX2's I2C controller has no hardware timeout -- if a slave device holds SCL low (clock stretching), or if an electrical fault prevents `bmDONE` from asserting, the firmware will spin forever in a polling loop.
-
-### The Problem with fx2lib
-
-The fx2lib `i2c_write()` and `i2c_read()` functions poll `bmDONE` and `bmSTOP` with loops like:
-
-```c
-while ( !(I2CS & bmDONE) && !cancel_i2c_trans);
-```
-
-The `cancel_i2c_trans` flag is declared as `volatile __xdata BOOL` and is set to `FALSE` at the start of each transaction. The library documentation says firmware can set it to `TRUE` from an interrupt to abort a stuck transaction. In practice, nothing in the firmware sets it, so these loops are effectively:
-
-```c
-while (!(I2CS & bmDONE)); // infinite if bmDONE never asserts
-```
-
-### Timeout-Protected Replacements
-
-The custom firmware replaces all fx2lib I2C functions with timeout-protected wrappers:
-
-```c
-#define I2C_TIMEOUT 6000
-
-static BOOL i2c_wait_done(void) {
- WORD timeout = I2C_TIMEOUT;
- while (!(I2CS & bmDONE)) {
- if (--timeout == 0)
- return FALSE;
- }
- return TRUE;
-}
-
-static BOOL i2c_wait_stop(void) {
- WORD timeout = I2C_TIMEOUT;
- while (I2CS & bmSTOP) {
- if (--timeout == 0)
- return FALSE;
- }
- return TRUE;
-}
-```
-
-A `WORD` counter of 6000, decremented in a tight SDCC-compiled loop at 48MHz (4 clocks per 8051 machine cycle, ~12 MIPS), gives approximately 5-10ms per wait. At 400kHz I2C, a single byte transfer (9 clock pulses) takes 22.5 microseconds, so this timeout provides well over 200x margin for normal operations while still bounding the worst case.
-
-All BCM4500 I2C operations -- `i2c_combined_read`, `i2c_write_timeout`, `i2c_write_multi_timeout` -- use these timeout-protected waits and return `FALSE` on timeout, allowing the caller to report failure rather than hanging the firmware.
-
-## Kernel Driver Race Condition
-
-The `dvb_usb_gp8psk` kernel module auto-loads via udev when VID:PID `09C0:0203` appears on the USB bus. This happens every time the FX2 re-enumerates after firmware load. The kernel driver races with the test tools and sends its own `BOOT_8PSK` command (along with other initialization), which interferes with debugging.
-
-Symptoms of this race condition:
-- Test scripts report "resource busy" or "entity not found" errors
-- The BCM4500 enters an unexpected state because the kernel driver partially initialized it
-- The kernel driver detaches from the device mid-test
-
-The fix is to blacklist the module:
-
-```
-# /etc/modprobe.d/blacklist-gp8psk.conf
-blacklist dvb_usb_gp8psk
-blacklist gp8psk_fe
-```
-
-After creating this file, run `sudo modprobe -r dvb_usb_gp8psk gp8psk_fe` to unload any currently-loaded instances. The blacklist prevents udev from auto-loading the module on device insertion, giving test tools exclusive access.
-
-## I2C Bus Scan Results
-
-Vendor command `0xB4` performs a full 7-bit I2C bus scan by attempting a START + address + WRITE to every address from 0x01 to 0x77 and checking for ACK. Three devices were found:
-
-| Address | Identity |
-|---------|----------|
-| `0x08` | BCM4500 demodulator. Status register `0xA2` returns valid data. This is the primary device for all demodulator operations. |
-| `0x10` | Likely the tuner or LNB controller. The SkyWalker-1 uses a separate tuner IC (accessed through the BCM4500 in normal operation, but also directly addressable on the shared I2C bus). |
-| `0x51` | Likely a configuration EEPROM. Many DVB-S receivers store tuner calibration data or device serial numbers in a small I2C EEPROM at addresses in the 0x50-0x57 range. |
-
-The BCM4500's 7-bit I2C address of `0x08` corresponds to 8-bit wire addresses of `0x10` (write) and `0x11` (read).
-
-## BCM4500 Boot Results After Fix
-
-With the `bmSTOP` removed, the full boot sequence completes reliably:
-
-- **Boot time:** ~90ms total (30ms power settle + 50ms post-reset delay + ~10ms I2C init)
-- **config_status:** `0x03` (STARTED | FW_LOADED)
-- **boot_stage:** `0xFF` (COMPLETE)
-- **Direct registers 0xA2-0xA8:** All return `0x02` (powered, not locked -- expected without a satellite signal)
-- **Signal lock:** `0x00` (no lock -- dish not aimed at satellite)
-- **Signal strength:** All zeros (same reason)
-- **USB responsiveness:** No hang. The firmware remains fully responsive to vendor commands throughout boot and afterward.
-
-## Firmware v3.01.0 Boot Sequence (Corrected)
-
-The complete boot sequence as implemented in `bcm4500_boot()`:
-
-1. **Assert BCM4500 RESET** -- Drive P0.5 LOW. This holds the BCM4500's digital logic in reset while power is applied.
-
-2. **Power on** -- Set P0.1 HIGH (power enable), P0.2 LOW (power disable off). The SkyWalker-1 has complementary power control pins.
-
-3. **delay(30ms)** -- Allow the power supply to settle and reach regulation. The stock firmware uses the same delay.
-
-4. **Release RESET** -- Drive P0.5 HIGH. The BCM4500 begins its internal power-on reset (POR) and mask ROM boot sequence.
-
-5. **delay(50ms)** -- Wait for the BCM4500's POR and internal initialization to complete. The chip needs time for its internal oscillator to stabilize and mask ROM to execute.
-
-6. **I2C probe** -- Read direct register `0xA2` (status) to verify the chip is alive and responding on I2C. If this fails, the boot aborts.
-
-7. **Write init block 0** -- 7 bytes to BCM4500 indirect page 0, starting at register `0x06`. Written via the `0xA6`/`0xA7`/`0xA8` indirect register protocol. Data: `{0x06, 0x0b, 0x17, 0x38, 0x9f, 0xd9, 0x80}`.
-
-8. **Write init block 1** -- 8 bytes to page 0, starting at register `0x07`. Data: `{0x07, 0x09, 0x39, 0x4f, 0x00, 0x65, 0xb7, 0x10}`.
-
-9. **Write init block 2** -- 3 bytes to page 0, starting at register `0x0F`. Data: `{0x0f, 0x0c, 0x09}`.
-
-10. **Set config_status** -- OR in `BM_STARTED | BM_FW_LOADED` (`0x03`). Subsequent vendor commands (tuning, signal strength readout, etc.) check this flag before operating.
-
-The three initialization blocks were extracted from disassembly of the stock v2.06 firmware's `FUN_CODE_0ddd` routine, which performs the same indirect register writes.
-
-## FX2 Hardware Recovery Note
-
-The FX2's CPUCS register at address `0xE600` controls the 8051 CPU's run/halt state. It is accessible via the standard vendor request bRequest=0xA0 (RAM read/write) even when the user firmware is completely hung in an infinite loop.
-
-This works because bRequest=0xA0 is handled by the FX2 silicon's boot ROM, not by firmware. The boot ROM's USB handler runs in a hardware-priority context that preempts the 8051's main loop. Writing `0x01` to CPUCS halts the CPU, new firmware can be loaded into RAM, and writing `0x00` starts it again.
-
-This means `fw_load.py` can reload firmware over a hung device without requiring a physical USB unplug/replug or power cycle. For iterative firmware development, this is significant -- a failed boot attempt that hangs the firmware can be recovered from the host side in seconds:
-
-```bash
-sudo python3 tools/fw_load.py load firmware/build/skywalker1.ihx --wait 3
-```
-
-The load sequence halts the CPU (CPUCS=0x01), writes new code into RAM, then restarts the CPU (CPUCS=0x00). The device re-enumerates with the new firmware.
+# BOOT_8PSK Debugging Findings
+
+Technical reference for the BCM4500 demodulator boot sequence on the Genpix SkyWalker-1 (Cypress FX2 CY7C68013A + Broadcom BCM4500), firmware v3.01.0. Documents the root cause analysis of a firmware hang during I2C initialization and the fixes applied.
+
+**Hardware:** Genpix SkyWalker-1 USB 2.0 DVB-S receiver
+**MCU:** Cypress CY7C68013A (FX2LP), 8051 core at 48MHz
+**Demodulator:** Broadcom BCM4500
+**Firmware:** Custom v3.01.0 (SDCC + fx2lib)
+**I2C bus speed:** 400kHz
+
+---
+
+## The Problem
+
+Custom firmware v3.01.0 implements vendor command `BOOT_8PSK` (bRequest=0x89, wValue=1), which powers on the BCM4500 demodulator and initializes it via I2C. When first tested, this command caused the FX2 firmware to hang for over 10 seconds, making the USB device completely unresponsive -- no vendor command would return, and the host-side USB stack would report timeout errors.
+
+The initial suspicion was infinite I2C loops. The fx2lib I2C library uses bare `while` loops that poll hardware status bits with no timeout:
+
+```c
+// fx2lib/lib/i2c.c -- original code
+while ( !(I2CS & bmDONE) && !cancel_i2c_trans);
+```
+
+The `cancel_i2c_trans` variable is intended as an external abort mechanism, but nothing in the firmware sets it during normal operation. If the I2C controller never asserts `bmDONE` (for example, because a slave is holding SCL low), the firmware spins indefinitely in this loop.
+
+Adding I2C timeout protection (described below) eliminated the infinite-hang symptom, but the boot sequence still failed: the BCM4500 probe read returned NACK, and all three register initialization blocks failed.
+
+## Root Cause: Spurious I2C STOP Condition
+
+The boot function originally included a so-called "I2C bus reset" step before any I2C communication:
+
+```c
+I2CS |= bmSTOP;
+i2c_wait_stop();
+```
+
+This pattern appears in various FX2 example code and seems reasonable on its face -- send a STOP condition to ensure the I2C bus is in a known idle state before starting fresh. On the FX2's I2C controller hardware, this is incorrect.
+
+### Incremental Debug Modes
+
+The root cause was discovered through a series of incremental debug modes added to the `BOOT_8PSK` vendor command handler. Each mode executes a subset of the full boot sequence, isolating which step introduces the failure:
+
+| wValue | Action | Result |
+|--------|--------|--------|
+| `0x80` | No-op: return `config_status` and `boot_stage` only | Works |
+| `0x81` | GPIO + power + delays only (no I2C at all) | Works |
+| `0x82` | GPIO + power + `bmSTOP` + I2C probe read | **Fails** |
+| `0x83` | GPIO + power + `bmSTOP` + probe + init block 0 | **Fails** (same root cause) |
+| `0x84` | `bcm_direct_read` only (no GPIO, chip already powered) | Works |
+| `0x85` | GPIO + power + reset, **no** `bmSTOP`, then probe | Works |
+
+Three observations clinch the diagnosis:
+
+1. **Mode 0x82 fails but mode 0x85 succeeds.** These two modes are identical except that 0x82 issues `I2CS |= bmSTOP` before the probe read and 0x85 does not. The `bmSTOP` is the only difference, and it is the only thing that breaks I2C.
+
+2. **Mode 0x84 succeeds immediately after 0x82 fails.** Mode 0x84 calls `bcm_direct_read` with no GPIO manipulation or bus reset -- just a plain I2C combined read. If called after a failed 0x82, it succeeds. This proves two things: the BCM4500 is alive and responding on I2C, and the `i2c_combined_read` function itself is correct. The failure in 0x82 is not a timing or power issue.
+
+3. **Raw I2C reads via vendor command 0xB5 succeed after 0x82 fails.** Command 0xB5 uses the same `i2c_combined_read` function as `bcm_direct_read`. Running it from the host side after a failed 0x82 returns valid data from the BCM4500. This confirms the chip was alive the whole time -- the FX2's I2C controller was in a bad state, not the bus or the slave.
+
+The test scripts that drove this investigation are in the `tools/` directory:
+
+- `test_boot_debug.py` -- sends debug modes 0x80 through 0x83 sequentially
+- `test_i2c_debug.py` -- powers on via 0x81, runs bus scans, tests probe timing
+- `test_i2c_isolate.py` -- tests whether re-reset or insufficient delay causes failure
+- `test_i2c_pinpoint.py` -- the definitive test: compares 0x84, 0x85, and 0x82
+
+### What Happens Inside the FX2 I2C Controller
+
+The FX2's I2C master controller is a hardware peripheral accessed through the `I2CS`, `I2DAT`, and `I2CTL` SFRs. The controller implements an I2C state machine in silicon. Writing `bmSTOP` to `I2CS` instructs the hardware to generate a STOP condition (SDA rising while SCL is high).
+
+When no I2C transaction is active -- no prior START has been issued, and the bus is idle -- writing `bmSTOP` puts the controller into an inconsistent internal state. The `bmSTOP` bit may not clear properly (it is supposed to self-clear when the STOP condition completes on the bus), and subsequent START conditions fail to generate proper clock sequences or detect ACK from slaves.
+
+The Cypress TRM (EZ-USB Technical Reference Manual) does not explicitly warn against this, but the I2C chapter describes STOP as a step that follows a completed read or write transaction. It is not documented as a standalone bus-reset mechanism.
+
+The correct way to ensure a clean I2C bus state on the FX2 is to simply proceed with a new START condition. If the bus is idle (which it will be after power-on or after the previous transaction completed normally), the START succeeds and the controller enters its normal operating state. The hardware handles bus arbitration automatically on START.
+
+## The Fix
+
+The fix is a single deletion. Remove the spurious STOP from the boot sequence:
+
+```c
+/* BEFORE (broken): */
+I2CS |= bmSTOP;
+i2c_wait_stop();
+
+/* AFTER (correct): */
+/* NOTE: Do NOT send I2CS bmSTOP here. Sending STOP when no transaction
+ * is active corrupts the FX2 I2C controller state, causing subsequent
+ * START+ACK detection to fail. The I2C bus will be in a clean state
+ * when we reach the probe step -- any prior transaction ended with STOP. */
+```
+
+The corrected `bcm4500_boot()` function proceeds directly from GPIO/power setup to the I2C probe read without any bus-reset step:
+
+```c
+static BOOL bcm4500_boot(void) {
+ boot_stage = 1;
+ cancel_i2c_trans = FALSE;
+
+ /* P3.7, P3.6, P3.5 HIGH (idle state for control lines) */
+ IOD |= 0xE0;
+
+ /* Assert BCM4500 hardware RESET (P0.5 LOW) */
+ OEA |= PIN_BCM_RESET;
+ IOA &= ~PIN_BCM_RESET;
+
+ /* No I2CS bmSTOP here -- see note above */
+
+ /* Power on: P0.1 HIGH (enable), P0.2 LOW (disable off) */
+ OEA |= (PIN_PWR_EN | PIN_PWR_DIS);
+ IOA = (IOA & ~PIN_PWR_DIS) | PIN_PWR_EN;
+
+ boot_stage = 2;
+ delay(30); /* power settle */
+
+ IOA |= PIN_BCM_RESET; /* release reset */
+ delay(50); /* BCM4500 POR + mask ROM boot */
+
+ boot_stage = 3;
+ /* I2C probe -- if this fails, the chip didn't come out of reset */
+ if (!bcm_direct_read(BCM_REG_STATUS, &i2c_rd[0]))
+ return FALSE;
+
+ /* ... register init blocks follow ... */
+}
+```
+
+## I2C Timeout Protection
+
+Even with the `bmSTOP` fix, timeout protection on all I2C operations is essential. The FX2's I2C controller has no hardware timeout -- if a slave device holds SCL low (clock stretching), or if an electrical fault prevents `bmDONE` from asserting, the firmware will spin forever in a polling loop.
+
+### The Problem with fx2lib
+
+The fx2lib `i2c_write()` and `i2c_read()` functions poll `bmDONE` and `bmSTOP` with loops like:
+
+```c
+while ( !(I2CS & bmDONE) && !cancel_i2c_trans);
+```
+
+The `cancel_i2c_trans` flag is declared as `volatile __xdata BOOL` and is set to `FALSE` at the start of each transaction. The library documentation says firmware can set it to `TRUE` from an interrupt to abort a stuck transaction. In practice, nothing in the firmware sets it, so these loops are effectively:
+
+```c
+while (!(I2CS & bmDONE)); // infinite if bmDONE never asserts
+```
+
+### Timeout-Protected Replacements
+
+The custom firmware replaces all fx2lib I2C functions with timeout-protected wrappers:
+
+```c
+#define I2C_TIMEOUT 6000
+
+static BOOL i2c_wait_done(void) {
+ WORD timeout = I2C_TIMEOUT;
+ while (!(I2CS & bmDONE)) {
+ if (--timeout == 0)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static BOOL i2c_wait_stop(void) {
+ WORD timeout = I2C_TIMEOUT;
+ while (I2CS & bmSTOP) {
+ if (--timeout == 0)
+ return FALSE;
+ }
+ return TRUE;
+}
+```
+
+A `WORD` counter of 6000, decremented in a tight SDCC-compiled loop at 48MHz (4 clocks per 8051 machine cycle, ~12 MIPS), gives approximately 5-10ms per wait. At 400kHz I2C, a single byte transfer (9 clock pulses) takes 22.5 microseconds, so this timeout provides well over 200x margin for normal operations while still bounding the worst case.
+
+All BCM4500 I2C operations -- `i2c_combined_read`, `i2c_write_timeout`, `i2c_write_multi_timeout` -- use these timeout-protected waits and return `FALSE` on timeout, allowing the caller to report failure rather than hanging the firmware.
+
+## Kernel Driver Race Condition
+
+The `dvb_usb_gp8psk` kernel module auto-loads via udev when VID:PID `09C0:0203` appears on the USB bus. This happens every time the FX2 re-enumerates after firmware load. The kernel driver races with the test tools and sends its own `BOOT_8PSK` command (along with other initialization), which interferes with debugging.
+
+Symptoms of this race condition:
+- Test scripts report "resource busy" or "entity not found" errors
+- The BCM4500 enters an unexpected state because the kernel driver partially initialized it
+- The kernel driver detaches from the device mid-test
+
+The fix is to blacklist the module:
+
+```
+# /etc/modprobe.d/blacklist-gp8psk.conf
+blacklist dvb_usb_gp8psk
+blacklist gp8psk_fe
+```
+
+After creating this file, run `sudo modprobe -r dvb_usb_gp8psk gp8psk_fe` to unload any currently-loaded instances. The blacklist prevents udev from auto-loading the module on device insertion, giving test tools exclusive access.
+
+## I2C Bus Scan Results
+
+Vendor command `0xB4` performs a full 7-bit I2C bus scan by attempting a START + address + WRITE to every address from 0x01 to 0x77 and checking for ACK. Three devices were found:
+
+| Address | Identity |
+|---------|----------|
+| `0x08` | BCM4500 demodulator. Status register `0xA2` returns valid data. This is the primary device for all demodulator operations. |
+| `0x10` | Likely the tuner or LNB controller. The SkyWalker-1 uses a separate tuner IC (accessed through the BCM4500 in normal operation, but also directly addressable on the shared I2C bus). |
+| `0x51` | Likely a configuration EEPROM. Many DVB-S receivers store tuner calibration data or device serial numbers in a small I2C EEPROM at addresses in the 0x50-0x57 range. |
+
+The BCM4500's 7-bit I2C address of `0x08` corresponds to 8-bit wire addresses of `0x10` (write) and `0x11` (read).
+
+## BCM4500 Boot Results After Fix
+
+With the `bmSTOP` removed, the full boot sequence completes reliably:
+
+- **Boot time:** ~90ms total (30ms power settle + 50ms post-reset delay + ~10ms I2C init)
+- **config_status:** `0x03` (STARTED | FW_LOADED)
+- **boot_stage:** `0xFF` (COMPLETE)
+- **Direct registers 0xA2-0xA8:** All return `0x02` (powered, not locked -- expected without a satellite signal)
+- **Signal lock:** `0x00` (no lock -- dish not aimed at satellite)
+- **Signal strength:** All zeros (same reason)
+- **USB responsiveness:** No hang. The firmware remains fully responsive to vendor commands throughout boot and afterward.
+
+## Firmware v3.01.0 Boot Sequence (Corrected)
+
+The complete boot sequence as implemented in `bcm4500_boot()`:
+
+1. **Assert BCM4500 RESET** -- Drive P0.5 LOW. This holds the BCM4500's digital logic in reset while power is applied.
+
+2. **Power on** -- Set P0.1 HIGH (power enable), P0.2 LOW (power disable off). The SkyWalker-1 has complementary power control pins.
+
+3. **delay(30ms)** -- Allow the power supply to settle and reach regulation. The stock firmware uses the same delay.
+
+4. **Release RESET** -- Drive P0.5 HIGH. The BCM4500 begins its internal power-on reset (POR) and mask ROM boot sequence.
+
+5. **delay(50ms)** -- Wait for the BCM4500's POR and internal initialization to complete. The chip needs time for its internal oscillator to stabilize and mask ROM to execute.
+
+6. **I2C probe** -- Read direct register `0xA2` (status) to verify the chip is alive and responding on I2C. If this fails, the boot aborts.
+
+7. **Write init block 0** -- 7 bytes to BCM4500 indirect page 0, starting at register `0x06`. Written via the `0xA6`/`0xA7`/`0xA8` indirect register protocol. Data: `{0x06, 0x0b, 0x17, 0x38, 0x9f, 0xd9, 0x80}`.
+
+8. **Write init block 1** -- 8 bytes to page 0, starting at register `0x07`. Data: `{0x07, 0x09, 0x39, 0x4f, 0x00, 0x65, 0xb7, 0x10}`.
+
+9. **Write init block 2** -- 3 bytes to page 0, starting at register `0x0F`. Data: `{0x0f, 0x0c, 0x09}`.
+
+10. **Set config_status** -- OR in `BM_STARTED | BM_FW_LOADED` (`0x03`). Subsequent vendor commands (tuning, signal strength readout, etc.) check this flag before operating.
+
+The three initialization blocks were extracted from disassembly of the stock v2.06 firmware's `FUN_CODE_0ddd` routine, which performs the same indirect register writes.
+
+## FX2 Hardware Recovery Note
+
+The FX2's CPUCS register at address `0xE600` controls the 8051 CPU's run/halt state. It is accessible via the standard vendor request bRequest=0xA0 (RAM read/write) even when the user firmware is completely hung in an infinite loop.
+
+This works because bRequest=0xA0 is handled by the FX2 silicon's boot ROM, not by firmware. The boot ROM's USB handler runs in a hardware-priority context that preempts the 8051's main loop. Writing `0x01` to CPUCS halts the CPU, new firmware can be loaded into RAM, and writing `0x00` starts it again.
+
+This means `fw_load.py` can reload firmware over a hung device without requiring a physical USB unplug/replug or power cycle. For iterative firmware development, this is significant -- a failed boot attempt that hangs the firmware can be recovered from the host side in seconds:
+
+```bash
+sudo python3 tools/fw_load.py load firmware/build/skywalker1.ihx --wait 3
+```
+
+The load sequence halts the CPU (CPUCS=0x01), writes new code into RAM, then restarts the CPU (CPUCS=0x00). The device re-enumerates with the new firmware.
diff --git a/docs/diseqc/diseqc-skywalker-1.md b/docs/diseqc/diseqc-skywalker-1.md
index 9bb74c1..58fa5d6 100644
--- a/docs/diseqc/diseqc-skywalker-1.md
+++ b/docs/diseqc/diseqc-skywalker-1.md
@@ -1,79 +1,79 @@
-# DiSEqC for the GenPix Skywalker-1 BDA Driver (Extended)
-
-**Implementation Guidelines for Applications**
-
-*Author: Devendra | Created: 2009-07-09 | Source: Microsoft Office Word 2007*
-
----
-
-## I. GUID for the SkyWalker1 Extended property
-
-```c
-//Used to extend the feature of the BDA
-//{0B5221EB-F4C4-4976-B959-EF74427464D9}
-#define STATIC_KSPROPSETID_BdaExtendedProperty \
- 0x0B5221EB, 0xF4C4, 0x4976, 0xB9, 0x59, 0xEF, 0x74, 0x42, 0x74, 0x64, 0xD9
-
-DEFINE_GUIDSTRUCT("0B5221EB-F4C4-4976-B959-EF74427464D9", KSPROPSETID_BdaExtendedProperty);
-#define KSPROPSETID_BdaExtendedProperty DEFINE_GUIDNAMED(KSPROPSETID_BdaExtendedProperty)
-```
-
-## II. Extended Property List (Only DiSEqC support is extended)
-
-```c
-//Extended Property List
-typedef enum __KSPROPERTY_EXTENDED
-{
- /* DiSEqC Command */
- //Used to send the Digital Satellite Equipment Control (DiSEqC)
- //Commands by application
- KSPROPERTY_BDA_DISEQC = 0, //Extension Property 1
-} KSPROPERTY_EXTENDED;
-```
-
-## III. Enumeration for the Simple Tone Burst
-
-```c
-typedef enum enSimpleToneBurst
-{
- SEC_MINI_A,
- SEC_MINI_B
-} SIMPLE_TONE_BURST;
-```
-
-## IV. DiSEqC Command Structure
-
-```c
-typedef struct __DISEQC_COMMAND
-{
- UCHAR ucMessage[MAX_DISEQC_COMMAND_LENGTH];
- /* Byte - 0 : Framing,
- Byte - 1 : Address,
- Byte - 2 : Command,
- Byte - 3 : Data[0],
- Byte - 4 : Data[1],
- Byte - 5 : Data[2] */
-
- UCHAR ucMessageLength;
- /* The Valid values for DiSEqC Command are 3...6
- If this value is 1 then Byte 0 is taken as Simple "Tone Burst"
- Control Command */
-} DISEQC_COMMAND, *PDISEQC_COMMAND;
-```
-
-## V. Operation
-
-### i. To send the Simple Burst command
-
-1. Create the `DISEQC_COMMAND` Structure
-2. Set `ucMessage[0]` to either `SEC_MINI_A` or `SEC_MINI_B`
-3. Set `ucMessageLength` as `1`
-
-### ii. To send DiSEqC commands
-
-1. Create the `DISEQC_COMMAND` Structure
-2. Set the Framing value to `ucMessage[0]` (e.g. `0xE0`)
-3. Set the Device Address to `ucMessage[1]` (e.g. `0x01`)
-4. Send the Command for the Device to `ucMessage[2]`
-5. If required, set the Data bytes `ucMessage[3]`, `ucMessage[4]`, `ucMessage[5]`
-6. Set `ucMessageLength` accordingly. Valid values are 3 to 6.
+# DiSEqC for the GenPix Skywalker-1 BDA Driver (Extended)
+
+**Implementation Guidelines for Applications**
+
+*Author: Devendra | Created: 2009-07-09 | Source: Microsoft Office Word 2007*
+
+---
+
+## I. GUID for the SkyWalker1 Extended property
+
+```c
+//Used to extend the feature of the BDA
+//{0B5221EB-F4C4-4976-B959-EF74427464D9}
+#define STATIC_KSPROPSETID_BdaExtendedProperty \
+ 0x0B5221EB, 0xF4C4, 0x4976, 0xB9, 0x59, 0xEF, 0x74, 0x42, 0x74, 0x64, 0xD9
+
+DEFINE_GUIDSTRUCT("0B5221EB-F4C4-4976-B959-EF74427464D9", KSPROPSETID_BdaExtendedProperty);
+#define KSPROPSETID_BdaExtendedProperty DEFINE_GUIDNAMED(KSPROPSETID_BdaExtendedProperty)
+```
+
+## II. Extended Property List (Only DiSEqC support is extended)
+
+```c
+//Extended Property List
+typedef enum __KSPROPERTY_EXTENDED
+{
+ /* DiSEqC Command */
+ //Used to send the Digital Satellite Equipment Control (DiSEqC)
+ //Commands by application
+ KSPROPERTY_BDA_DISEQC = 0, //Extension Property 1
+} KSPROPERTY_EXTENDED;
+```
+
+## III. Enumeration for the Simple Tone Burst
+
+```c
+typedef enum enSimpleToneBurst
+{
+ SEC_MINI_A,
+ SEC_MINI_B
+} SIMPLE_TONE_BURST;
+```
+
+## IV. DiSEqC Command Structure
+
+```c
+typedef struct __DISEQC_COMMAND
+{
+ UCHAR ucMessage[MAX_DISEQC_COMMAND_LENGTH];
+ /* Byte - 0 : Framing,
+ Byte - 1 : Address,
+ Byte - 2 : Command,
+ Byte - 3 : Data[0],
+ Byte - 4 : Data[1],
+ Byte - 5 : Data[2] */
+
+ UCHAR ucMessageLength;
+ /* The Valid values for DiSEqC Command are 3...6
+ If this value is 1 then Byte 0 is taken as Simple "Tone Burst"
+ Control Command */
+} DISEQC_COMMAND, *PDISEQC_COMMAND;
+```
+
+## V. Operation
+
+### i. To send the Simple Burst command
+
+1. Create the `DISEQC_COMMAND` Structure
+2. Set `ucMessage[0]` to either `SEC_MINI_A` or `SEC_MINI_B`
+3. Set `ucMessageLength` as `1`
+
+### ii. To send DiSEqC commands
+
+1. Create the `DISEQC_COMMAND` Structure
+2. Set the Framing value to `ucMessage[0]` (e.g. `0xE0`)
+3. Set the Device Address to `ucMessage[1]` (e.g. `0x01`)
+4. Send the Command for the Device to `ucMessage[2]`
+5. If required, set the Data bytes `ucMessage[3]`, `ucMessage[4]`, `ucMessage[5]`
+6. Set `ucMessageLength` accordingly. Valid values are 3 to 6.
diff --git a/dvb-s2-investigation.md b/dvb-s2-investigation.md
index 474c54d..1d0f221 100644
--- a/dvb-s2-investigation.md
+++ b/dvb-s2-investigation.md
@@ -1,255 +1,255 @@
-# DVB-S2 Incompatibility Investigation: Genpix SkyWalker-1
-
-## Definitive Conclusion
-
-**The SkyWalker-1's inability to receive DVB-S2 is a fundamental hardware limitation of the Broadcom BCM4500 demodulator silicon, not a firmware limitation.** The BCM4500 was designed and fabricated before the DVB-S2 standard was ratified (2005) and contains no LDPC or BCH decoder hardware. DVB-S2 requires LDPC (Low-Density Parity-Check) and BCH (Bose-Chaudhuri-Hocquenghem) forward error correction -- entirely different decoder architectures from the Viterbi/turbo/Reed-Solomon decoders present in the BCM4500. No firmware update could add DVB-S2 support to this hardware.
-
-Genpix eventually addressed this by releasing the SkyWalker-3, which replaced the entire demodulator subsystem (likely switching from Broadcom BCM4500 to STMicroelectronics STV0903), trading turbo-FEC support for DVB-S2 LDPC/BCH capability.
-
----
-
-## 1. Does the BCM4500 Silicon Support DVB-S2?
-
-**No. The BCM4500 has no LDPC or BCH decoder hardware.**
-
-### BCM4500 FEC Architecture (from datasheet)
-
-The BCM4500 contains exactly two FEC decoder paths:
-
-1. **Advanced Modulation Turbo FEC Decoder** -- an iterative turbo code decoder supporting:
- - QPSK: rates 1/4, 1/2, 3/4
- - 8PSK: rates 2/3, 3/4, 5/6, 8/9
- - 16QAM: rate 3/4
- - Reed-Solomon outer code (t=10) after turbo decoding
-
-2. **Legacy DVB/DIRECTV/DCII-Compliant FEC Decoder** -- a concatenated coding chain:
- - Inner: Viterbi decoder (convolutional code, rates 1/2 through 7/8)
- - Outer: Reed-Solomon decoder
-
-The datasheet describes the signal path explicitly: "Optimized soft decisions are then fed into either a DVB/DIRECTV/DCII-compliant FEC decoder, or an advanced modulation turbo decoder." These are the only two paths. There is no third path for LDPC/BCH.
-
-### DVB-S2 FEC Architecture (for comparison)
-
-DVB-S2 (EN 302 307, ratified March 2005) mandates:
-
-- **Inner code**: LDPC (Low-Density Parity-Check) -- block lengths of 64,800 or 16,200 bits
-- **Outer code**: BCH (Bose-Chaudhuri-Hocquenghem)
-- **Code rates**: 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 8/9, 9/10
-
-LDPC decoding requires dedicated hardware: large block RAM for message passing (the LDPC block size is 64,800 bits, requiring significant on-chip storage), iterative belief propagation logic, and a fundamentally different decoder architecture from both Viterbi and turbo decoders. This cannot be emulated in firmware on the BCM4500's simple 8-bit on-chip microcontroller (used only for configuration, acquisition, and monitoring -- not data-path processing).
-
-### Evidence from the BCM4500 Datasheet
-
-Source: [BCM4500 Datasheet (DatasheetQ)](https://html.datasheetq.com/pdf-html/885700/Broadcom/2page/BCM4500.html), [BCM4500 Datasheet (Elcodis)](https://elcodis.com/parts/5786421/BCM4500.html)
-
-Key specifications confirming no DVB-S2 capability:
-- Modulation: BPSK, QPSK, 8PSK, 16QAM (no mention of DVB-S2-specific constellations)
-- FEC: "advanced modulation turbo FEC decoder" and "DVB/DIRECTV/DCII-compliant FEC decoder"
-- Symbol rate: 256 Ksps to 30 Msps
-- Package: 128-pin MQFP
-- Supply: 3.3V I/O, 1.8V digital
-- No mention of LDPC, BCH, or DVB-S2 anywhere in the datasheet
-
----
-
-## 2. What FEC Types Does the BCM4500 Actually Support?
-
-The BCM4500 supports three distinct FEC coding families, none of which are DVB-S2 compatible:
-
-### 2.1 Viterbi + Reed-Solomon (Legacy DVB-S / DSS / DCII)
-
-Used for standard DVB-S QPSK, DSS QPSK, DVB-S BPSK, and Digicipher II modes.
-
-**Firmware evidence** (from `skywalker1-hardware-reference.md`, Section 6.3):
-- FEC lookup table at XRAM 0xE0F9, maximum index 7
-- Modulation dispatch sets XRAM 0xE0F6 = 0x00 (turbo flag OFF)
-- XRAM 0xE0F5 = 0x10 (standard demod mode)
-- The firmware FEC table supports rates: 1/2, 2/3, 3/4, 5/6, 7/8, auto, none
-
-**Windows driver evidence** (`SkyWalker1Control.h`, line 59):
-```c
-m_CurResource.ulInnerFecType = BDA_FEC_VITERBI;
-```
-
-**Windows driver evidence** (`SkyWalker1TunerFilter.cpp`, lines 1069-1070):
-```c
-//Only supported FEC VITERBI Type Error Correction
-else if(ulNewInnerFecType == BDA_FEC_VITERBI)
-```
-
-The Windows BDA driver explicitly rejects any FEC type other than `BDA_FEC_VITERBI` and restricts code rates to 1/2, 2/3, 3/4, 5/6, 7/8 (lines 1112-1116). There is no `BDA_FEC_LDPC` handling.
-
-### 2.2 Turbo Codes (Proprietary 8PSK/QPSK/16QAM)
-
-Used for Turbo QPSK, Turbo 8PSK, and Turbo 16QAM -- the proprietary "advanced modulation" modes developed by Broadcom for EchoStar/Dish Network.
-
-**Firmware evidence** (from `tuning-protocol-analysis.md`, Section 3):
-- Turbo QPSK: FEC table at XRAM 0xE0B7, max index 5
-- Turbo 8PSK: FEC table at XRAM 0xE0B1, max index 5
-- Turbo 16QAM: FEC table at XRAM 0xE0BC, max index 1
-- All turbo modes set XRAM 0xE0F6 = 0x01 (turbo flag ON)
-
-These turbo codes are proprietary to EchoStar/Broadcom. They are NOT the same as DVB-S2's LDPC codes, despite both being "advanced" coding schemes. The turbo decoder uses a fundamentally different iterative decoding algorithm (parallel concatenated convolutional codes) compared to LDPC (sparse parity-check matrix belief propagation).
-
-### 2.3 Digicipher II (Motorola/GI Proprietary)
-
-Used for DCII combo, split I/Q, and offset QPSK modes.
-
-**Firmware evidence**: FEC table at XRAM 0xE0BD, max index 9, with a fixed FEC code of 0xFC written to XRAM 0xE0EB.
-
-### Summary: FEC Architecture Comparison
-
-| Feature | BCM4500 (SkyWalker-1) | DVB-S2 Requirement |
-|---------|----------------------|-------------------|
-| Inner FEC | Viterbi (DVB-S) or Turbo (proprietary) | LDPC |
-| Outer FEC | Reed-Solomon (t=10) | BCH |
-| Block size | Convolutional (streaming) / Turbo (short blocks) | 64,800 or 16,200 bits |
-| Decoder type | Trellis-based (Viterbi) or iterative turbo | Iterative belief propagation |
-| Hardware IP | Hardwired Viterbi + turbo silicon | Requires dedicated LDPC engine |
-| Standardization | DVB-S (ETSI EN 300 421) + proprietary turbo | DVB-S2 (ETSI EN 302 307) |
-
----
-
-## 3. What Would a DVB-S2-Capable Replacement Look Like?
-
-### Broadcom's Own DVB-S2 Chip Timeline
-
-Broadcom addressed DVB-S2 by designing entirely new silicon:
-
-| Chip | Year | DVB-S2? | Key Feature | Source |
-|------|------|---------|-------------|--------|
-| **BCM4500** | ~2003 | No | Turbo FEC + legacy Viterbi/RS | [Datasheet](https://elcodis.com/parts/5786421/BCM4500.html) |
-| **BCM4501** | 2006 | **Yes** | First dual-tuner DVB-S2 receiver; LDPC/BCH decoder | [Broadcom](https://www.broadcom.com/products/broadband/set-top-box/bcm4501), [EDN](https://www.edn.com/bcm4501-dual-dvb-s2-advanced-modulation-satellite-receiver/) |
-| **BCM4505** | 2007 | **Yes** | Single-channel, 65nm, LDPC/BCH + legacy | [Broadcom](https://www.broadcom.com/products/broadband/set-top-box/bcm4505) |
-| **BCM4506** | 2007 | **Yes** | Dual-channel, 65nm, LDPC/BCH + legacy | [Broadcom](https://www.broadcom.com/products/broadband/set-top-box/bcm4506) |
-
-The BCM4501 datasheet explicitly states it includes "four 8-bit ADCs, all-digital variable rate QPSK/8PSK receivers, advanced modulation LDPC/BCH, and DVB-S-compliant forward error correction decoder." The addition of LDPC/BCH required new silicon -- it was not a firmware upgrade to the BCM4500.
-
-However, Broadcom restricted sales of these chips to set-top box manufacturers (EchoStar, DIRECTV) and did not sell to PC peripheral makers. This is why Genpix could not simply drop in a BCM4501.
-
-### What Genpix Actually Did: The SkyWalker-3
-
-Genpix released the SkyWalker-3 as a DVB-S2-capable successor, using a completely different demodulator:
-
-| Feature | SkyWalker-1 (BCM4500) | SkyWalker-3 (likely STV0903) |
-|---------|----------------------|---------------------------|
-| DVB-S QPSK | Yes | Yes |
-| DVB-S2 QPSK | No | Yes (rates 1/2 through 9/10) |
-| DVB-S2 8PSK | No | Yes (rates 3/5 through 9/10) |
-| Turbo QPSK | Yes | **No** |
-| Turbo 8PSK | Yes | **No** |
-| Turbo 16QAM | Yes | **No** |
-| DCII | Yes | Yes |
-| DSS | Yes | Yes |
-| Symbol rate (DVB-S) | 256 Ksps - 30 Msps | 1 - 45 Msps |
-| Symbol rate (DVB-S2) | N/A | 5 - 33 Msps |
-| FEC inner (DVB-S) | Viterbi | Viterbi |
-| FEC inner (DVB-S2) | N/A | LDPC |
-| FEC outer (DVB-S2) | N/A | BCH |
-| Demodulator | Broadcom BCM4500 | STMicroelectronics STV0903 (probable) |
-| Tuner | Broadcom BCM3440 | STMicroelectronics STV6110 (probable) |
-
-Source: [Genpix SkyWalker-3 specifications](https://www.genpix-electronics.com/what-is-skywalker-3.html)
-
-The trade-off is visible: the SkyWalker-3 gained DVB-S2 but lost turbo-FEC support entirely. The turbo codes were proprietary to Broadcom/EchoStar, and the STMicroelectronics STV0903 demodulator does not implement them. This means the SkyWalker-3 cannot receive Dish Network's legacy turbo-coded 8PSK transmissions.
-
----
-
-## 4. Are There Any Hints of DVB-S2 Awareness in the Firmware?
-
-**No. There are zero references to DVB-S2, LDPC, or BCH in any firmware version or in the Windows driver source.**
-
-### Firmware Search Results
-
-Searched all three firmware versions (v2.06, Rev.2 v2.10, v2.13) via Ghidra disassembly and the following source files:
-
-- `SkyWalker1Control.h` -- defines modulation constants 0-9, none related to DVB-S2
-- `SkyWalker1CommonDef.h` -- device parameter structure uses `BDA_FEC_VITERBI` only
-- `SkyWalker1TunerFilter.cpp` -- explicitly rejects non-QPSK modulation types and non-Viterbi FEC
-- `SkyWalker1Control.cpp` -- hardcodes `ADV_MOD_DVB_QPSK` (value 0) in tune command byte 8
-
-**Specific evidence of no DVB-S2 awareness:**
-
-1. **Modulation enum caps at 9** (`SkyWalker1Control.h`, lines 64-74): The modulation constants are `ADV_MOD_DVB_QPSK` (0) through `ADV_MOD_DVB_BPSK` (9). No value 10+ exists for DVB-S2 modes.
-
-2. **Firmware dispatch table has exactly 10 entries** (`tuning-protocol-analysis.md`, Section 3.1): The jump table at CODE:0873 contains 20 bytes (10 entries x 2 bytes). Modulation values >= 10 are rejected by the bounds check at CODE:0866.
-
-3. **FEC type is hardcoded to Viterbi** (`SkyWalker1TunerFilter.cpp`, line 1070): `else if(ulNewInnerFecType == BDA_FEC_VITERBI)` -- only Viterbi is accepted; any other FEC type returns `STATUS_INVALID_PARAMETER`.
-
-4. **Tune command hardcodes DVB-S QPSK** (`SkyWalker1Control.cpp`, line 292): `ucCommand[8] = ADV_MOD_DVB_QPSK;` -- the Windows driver always sends modulation type 0 (DVB-S QPSK) regardless of what the application requests.
-
-5. **No LDPC/BCH code rate values** exist in any FEC lookup table. The firmware's XRAM tables at 0xE0B1, 0xE0B7, 0xE0BC, 0xE0BD, and 0xE0F9 contain only Viterbi rates (1/2 through 7/8), turbo rates, and DCII combined codes.
-
-6. **No DVB-S2-specific register addresses** appear in the I2C traffic. The BCM4500 is programmed exclusively through indirect registers 0xA6/0xA7/0xA8 with page 0x00 -- a protocol specific to the BCM4500. DVB-S2 demodulators like the STV0903 use entirely different register maps.
-
----
-
-## 5. Could the GPIF Streaming Path Handle DVB-S2 Data Rates?
-
-**Yes -- the USB data path is not the bottleneck. The GPIF/USB 2.0 streaming architecture could handle DVB-S2 data rates if the demodulator supported them.**
-
-### Data Rate Analysis
-
-**DVB-S2 maximum useful bit rate** (from ETSI EN 302 307):
-- Highest configuration: 8PSK, rate 9/10, 30 Msps = ~72 Mbps raw, ~58 Mbps net after FEC
-- Typical HD transponder: 8PSK, rate 3/4, 27.5 Msps = ~44 Mbps net
-
-**GPIF/USB 2.0 throughput capacity:**
-- USB 2.0 High Speed bulk: 480 Mbps theoretical, ~35 MB/s (~280 Mbps) practical
-- GPIF engine: 48 MHz clock, 8-bit data path = 48 MB/s (384 Mbps) theoretical
-- EP2 FIFO: 4x buffer with AUTOIN, 7 URBs x 8KB on host side
-
-**Current DVB-S usage** (from `gpif-streaming-analysis.md`, Section 15):
-- "Transport stream rate: BCM4500 outputs at the satellite symbol rate (up to 30 Msps), but the effective byte rate depends on modulation and coding. USB 2.0 High Speed bulk bandwidth (480 Mbps theoretical, ~35 MB/s practical) is more than sufficient for DVB-S transport streams (typically 1-5 MB/s)."
-
-**Assessment**: Even at the theoretical maximum DVB-S2 data rate of ~58 Mbps (~7.25 MB/s), the USB 2.0 bulk streaming path has approximately 5x headroom. The GPIF engine configuration (IFCONFIG=0xEE, EP2FIFOCFG=0x0C, FLOWSTATEA with FSEN enabled) is identical across all firmware versions and provides a fully hardware-managed pipeline that would not require modification.
-
-The 8-bit parallel transport stream interface between the demodulator and FX2 is also sufficient -- DVB-S2 uses the same MPEG-TS output format (188-byte packets) as DVB-S. The GPIF waveform and AUTOIN configuration would work unchanged.
-
-**However**, this is a moot point. The bottleneck is the demodulator silicon, not the data path. Even if you physically replaced the BCM4500 with a DVB-S2-capable chip, you would need to rewrite the entire FX2 firmware (I2C register protocol, tuning sequence, modulation dispatch, FEC configuration) since every DVB-S2 demodulator uses a completely different register interface.
-
----
-
-## Summary
-
-| Question | Answer |
-|----------|--------|
-| Is DVB-S2 a hardware or firmware limitation? | **Hardware** -- the BCM4500 has no LDPC/BCH decoder logic |
-| Could a firmware update add DVB-S2? | **No** -- LDPC decoding requires dedicated silicon |
-| Which Broadcom chip first added LDPC? | **BCM4501** (2006), followed by BCM4505/BCM4506 (2007) |
-| Any DVB-S2 hints in firmware/driver? | **None** -- zero references to LDPC, BCH, or DVB-S2 |
-| Is the USB data path a bottleneck? | **No** -- USB 2.0 bulk has ~5x headroom for DVB-S2 rates |
-| What did Genpix do for DVB-S2? | Released SkyWalker-3 with a different demodulator (likely STV0903) |
-| What was lost in the transition? | Turbo-FEC support (proprietary to Broadcom/EchoStar) |
-
----
-
-## Sources
-
-### Datasheets and Product Pages
-- [BCM4500 Datasheet (DatasheetQ)](https://html.datasheetq.com/pdf-html/885700/Broadcom/2page/BCM4500.html)
-- [BCM4500 Datasheet (Elcodis)](https://elcodis.com/parts/5786421/BCM4500.html)
-- [BCM4500 Datasheet (AllDatasheet)](https://www.alldatasheet.com/datasheet-pdf/pdf/85246/BOARDCOM/BCM4500.html)
-- [BCM4501 Product Page (Broadcom)](https://www.broadcom.com/products/broadband/set-top-box/bcm4501)
-- [BCM4501 (EDN)](https://www.edn.com/bcm4501-dual-dvb-s2-advanced-modulation-satellite-receiver/)
-- [BCM4505 Product Page (Broadcom)](https://www.broadcom.com/products/broadband/set-top-box/bcm4505)
-- [BCM4506 Product Page (Broadcom)](https://www.broadcom.com/products/broadband/set-top-box/bcm4506)
-- [BCM4505/BCM4506 Announcement (RTTNews)](https://www.rttnews.com/380136/broadcom-launches-bcm4505-and-bcm4506-two-fully-integrated-single-chip-single-and-dual-channel-multi-format-satellite-receivers-quick-facts.aspx)
-
-### Genpix Products
-- [Genpix SkyWalker-3 Specifications](https://www.genpix-electronics.com/what-is-skywalker-3.html)
-- [Genpix Official Site](https://www.genpix-electronics.com/index.php?act=viewDoc&docId=9)
-
-### Community and Technical Discussions
-- [LinuxTV mailing list: BCM4500 and DVB-S2 distinction](https://www.mail-archive.com/linux-dvb@linuxtv.org/msg24808.html)
-- [SatelliteGuys: Turbo 8PSK card reverse engineering](https://www.satelliteguys.us/xen/threads/another-turbo-8psk-card.246879/)
-- [SatelliteGuys: Genpix SkyWalker-1 discussion](https://www.satelliteguys.us/xen/threads/genpix-skywalker-1.214196/)
-
-### Reverse Engineering Analysis (This Project)
-- `skywalker1-hardware-reference.md` -- Sections 1, 6, 7: Overview, tuning protocol, BCM4500 interface
-- `tuning-protocol-analysis.md` -- Section 3: Modulation dispatch table, FEC lookup tables
-- `gpif-streaming-analysis.md` -- Sections 13-15: GPIF throughput and data path analysis
-- `rev2-deep-analysis.md` -- Complete Rev.2 function inventory
-- `SkyWalker1Control.h` -- Modulation mode constants (lines 63-74), FEC/command definitions
-- `SkyWalker1TunerFilter.cpp` -- SetInnerFecType() Viterbi-only restriction (lines 1058-1086)
-- `SkyWalker1Control.cpp` -- TuneDevice() hardcoded ADV_MOD_DVB_QPSK (line 292)
+# DVB-S2 Incompatibility Investigation: Genpix SkyWalker-1
+
+## Definitive Conclusion
+
+**The SkyWalker-1's inability to receive DVB-S2 is a fundamental hardware limitation of the Broadcom BCM4500 demodulator silicon, not a firmware limitation.** The BCM4500 was designed and fabricated before the DVB-S2 standard was ratified (2005) and contains no LDPC or BCH decoder hardware. DVB-S2 requires LDPC (Low-Density Parity-Check) and BCH (Bose-Chaudhuri-Hocquenghem) forward error correction -- entirely different decoder architectures from the Viterbi/turbo/Reed-Solomon decoders present in the BCM4500. No firmware update could add DVB-S2 support to this hardware.
+
+Genpix eventually addressed this by releasing the SkyWalker-3, which replaced the entire demodulator subsystem (likely switching from Broadcom BCM4500 to STMicroelectronics STV0903), trading turbo-FEC support for DVB-S2 LDPC/BCH capability.
+
+---
+
+## 1. Does the BCM4500 Silicon Support DVB-S2?
+
+**No. The BCM4500 has no LDPC or BCH decoder hardware.**
+
+### BCM4500 FEC Architecture (from datasheet)
+
+The BCM4500 contains exactly two FEC decoder paths:
+
+1. **Advanced Modulation Turbo FEC Decoder** -- an iterative turbo code decoder supporting:
+ - QPSK: rates 1/4, 1/2, 3/4
+ - 8PSK: rates 2/3, 3/4, 5/6, 8/9
+ - 16QAM: rate 3/4
+ - Reed-Solomon outer code (t=10) after turbo decoding
+
+2. **Legacy DVB/DIRECTV/DCII-Compliant FEC Decoder** -- a concatenated coding chain:
+ - Inner: Viterbi decoder (convolutional code, rates 1/2 through 7/8)
+ - Outer: Reed-Solomon decoder
+
+The datasheet describes the signal path explicitly: "Optimized soft decisions are then fed into either a DVB/DIRECTV/DCII-compliant FEC decoder, or an advanced modulation turbo decoder." These are the only two paths. There is no third path for LDPC/BCH.
+
+### DVB-S2 FEC Architecture (for comparison)
+
+DVB-S2 (EN 302 307, ratified March 2005) mandates:
+
+- **Inner code**: LDPC (Low-Density Parity-Check) -- block lengths of 64,800 or 16,200 bits
+- **Outer code**: BCH (Bose-Chaudhuri-Hocquenghem)
+- **Code rates**: 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5, 5/6, 8/9, 9/10
+
+LDPC decoding requires dedicated hardware: large block RAM for message passing (the LDPC block size is 64,800 bits, requiring significant on-chip storage), iterative belief propagation logic, and a fundamentally different decoder architecture from both Viterbi and turbo decoders. This cannot be emulated in firmware on the BCM4500's simple 8-bit on-chip microcontroller (used only for configuration, acquisition, and monitoring -- not data-path processing).
+
+### Evidence from the BCM4500 Datasheet
+
+Source: [BCM4500 Datasheet (DatasheetQ)](https://html.datasheetq.com/pdf-html/885700/Broadcom/2page/BCM4500.html), [BCM4500 Datasheet (Elcodis)](https://elcodis.com/parts/5786421/BCM4500.html)
+
+Key specifications confirming no DVB-S2 capability:
+- Modulation: BPSK, QPSK, 8PSK, 16QAM (no mention of DVB-S2-specific constellations)
+- FEC: "advanced modulation turbo FEC decoder" and "DVB/DIRECTV/DCII-compliant FEC decoder"
+- Symbol rate: 256 Ksps to 30 Msps
+- Package: 128-pin MQFP
+- Supply: 3.3V I/O, 1.8V digital
+- No mention of LDPC, BCH, or DVB-S2 anywhere in the datasheet
+
+---
+
+## 2. What FEC Types Does the BCM4500 Actually Support?
+
+The BCM4500 supports three distinct FEC coding families, none of which are DVB-S2 compatible:
+
+### 2.1 Viterbi + Reed-Solomon (Legacy DVB-S / DSS / DCII)
+
+Used for standard DVB-S QPSK, DSS QPSK, DVB-S BPSK, and Digicipher II modes.
+
+**Firmware evidence** (from `skywalker1-hardware-reference.md`, Section 6.3):
+- FEC lookup table at XRAM 0xE0F9, maximum index 7
+- Modulation dispatch sets XRAM 0xE0F6 = 0x00 (turbo flag OFF)
+- XRAM 0xE0F5 = 0x10 (standard demod mode)
+- The firmware FEC table supports rates: 1/2, 2/3, 3/4, 5/6, 7/8, auto, none
+
+**Windows driver evidence** (`SkyWalker1Control.h`, line 59):
+```c
+m_CurResource.ulInnerFecType = BDA_FEC_VITERBI;
+```
+
+**Windows driver evidence** (`SkyWalker1TunerFilter.cpp`, lines 1069-1070):
+```c
+//Only supported FEC VITERBI Type Error Correction
+else if(ulNewInnerFecType == BDA_FEC_VITERBI)
+```
+
+The Windows BDA driver explicitly rejects any FEC type other than `BDA_FEC_VITERBI` and restricts code rates to 1/2, 2/3, 3/4, 5/6, 7/8 (lines 1112-1116). There is no `BDA_FEC_LDPC` handling.
+
+### 2.2 Turbo Codes (Proprietary 8PSK/QPSK/16QAM)
+
+Used for Turbo QPSK, Turbo 8PSK, and Turbo 16QAM -- the proprietary "advanced modulation" modes developed by Broadcom for EchoStar/Dish Network.
+
+**Firmware evidence** (from `tuning-protocol-analysis.md`, Section 3):
+- Turbo QPSK: FEC table at XRAM 0xE0B7, max index 5
+- Turbo 8PSK: FEC table at XRAM 0xE0B1, max index 5
+- Turbo 16QAM: FEC table at XRAM 0xE0BC, max index 1
+- All turbo modes set XRAM 0xE0F6 = 0x01 (turbo flag ON)
+
+These turbo codes are proprietary to EchoStar/Broadcom. They are NOT the same as DVB-S2's LDPC codes, despite both being "advanced" coding schemes. The turbo decoder uses a fundamentally different iterative decoding algorithm (parallel concatenated convolutional codes) compared to LDPC (sparse parity-check matrix belief propagation).
+
+### 2.3 Digicipher II (Motorola/GI Proprietary)
+
+Used for DCII combo, split I/Q, and offset QPSK modes.
+
+**Firmware evidence**: FEC table at XRAM 0xE0BD, max index 9, with a fixed FEC code of 0xFC written to XRAM 0xE0EB.
+
+### Summary: FEC Architecture Comparison
+
+| Feature | BCM4500 (SkyWalker-1) | DVB-S2 Requirement |
+|---------|----------------------|-------------------|
+| Inner FEC | Viterbi (DVB-S) or Turbo (proprietary) | LDPC |
+| Outer FEC | Reed-Solomon (t=10) | BCH |
+| Block size | Convolutional (streaming) / Turbo (short blocks) | 64,800 or 16,200 bits |
+| Decoder type | Trellis-based (Viterbi) or iterative turbo | Iterative belief propagation |
+| Hardware IP | Hardwired Viterbi + turbo silicon | Requires dedicated LDPC engine |
+| Standardization | DVB-S (ETSI EN 300 421) + proprietary turbo | DVB-S2 (ETSI EN 302 307) |
+
+---
+
+## 3. What Would a DVB-S2-Capable Replacement Look Like?
+
+### Broadcom's Own DVB-S2 Chip Timeline
+
+Broadcom addressed DVB-S2 by designing entirely new silicon:
+
+| Chip | Year | DVB-S2? | Key Feature | Source |
+|------|------|---------|-------------|--------|
+| **BCM4500** | ~2003 | No | Turbo FEC + legacy Viterbi/RS | [Datasheet](https://elcodis.com/parts/5786421/BCM4500.html) |
+| **BCM4501** | 2006 | **Yes** | First dual-tuner DVB-S2 receiver; LDPC/BCH decoder | [Broadcom](https://www.broadcom.com/products/broadband/set-top-box/bcm4501), [EDN](https://www.edn.com/bcm4501-dual-dvb-s2-advanced-modulation-satellite-receiver/) |
+| **BCM4505** | 2007 | **Yes** | Single-channel, 65nm, LDPC/BCH + legacy | [Broadcom](https://www.broadcom.com/products/broadband/set-top-box/bcm4505) |
+| **BCM4506** | 2007 | **Yes** | Dual-channel, 65nm, LDPC/BCH + legacy | [Broadcom](https://www.broadcom.com/products/broadband/set-top-box/bcm4506) |
+
+The BCM4501 datasheet explicitly states it includes "four 8-bit ADCs, all-digital variable rate QPSK/8PSK receivers, advanced modulation LDPC/BCH, and DVB-S-compliant forward error correction decoder." The addition of LDPC/BCH required new silicon -- it was not a firmware upgrade to the BCM4500.
+
+However, Broadcom restricted sales of these chips to set-top box manufacturers (EchoStar, DIRECTV) and did not sell to PC peripheral makers. This is why Genpix could not simply drop in a BCM4501.
+
+### What Genpix Actually Did: The SkyWalker-3
+
+Genpix released the SkyWalker-3 as a DVB-S2-capable successor, using a completely different demodulator:
+
+| Feature | SkyWalker-1 (BCM4500) | SkyWalker-3 (likely STV0903) |
+|---------|----------------------|---------------------------|
+| DVB-S QPSK | Yes | Yes |
+| DVB-S2 QPSK | No | Yes (rates 1/2 through 9/10) |
+| DVB-S2 8PSK | No | Yes (rates 3/5 through 9/10) |
+| Turbo QPSK | Yes | **No** |
+| Turbo 8PSK | Yes | **No** |
+| Turbo 16QAM | Yes | **No** |
+| DCII | Yes | Yes |
+| DSS | Yes | Yes |
+| Symbol rate (DVB-S) | 256 Ksps - 30 Msps | 1 - 45 Msps |
+| Symbol rate (DVB-S2) | N/A | 5 - 33 Msps |
+| FEC inner (DVB-S) | Viterbi | Viterbi |
+| FEC inner (DVB-S2) | N/A | LDPC |
+| FEC outer (DVB-S2) | N/A | BCH |
+| Demodulator | Broadcom BCM4500 | STMicroelectronics STV0903 (probable) |
+| Tuner | Broadcom BCM3440 | STMicroelectronics STV6110 (probable) |
+
+Source: [Genpix SkyWalker-3 specifications](https://www.genpix-electronics.com/what-is-skywalker-3.html)
+
+The trade-off is visible: the SkyWalker-3 gained DVB-S2 but lost turbo-FEC support entirely. The turbo codes were proprietary to Broadcom/EchoStar, and the STMicroelectronics STV0903 demodulator does not implement them. This means the SkyWalker-3 cannot receive Dish Network's legacy turbo-coded 8PSK transmissions.
+
+---
+
+## 4. Are There Any Hints of DVB-S2 Awareness in the Firmware?
+
+**No. There are zero references to DVB-S2, LDPC, or BCH in any firmware version or in the Windows driver source.**
+
+### Firmware Search Results
+
+Searched all three firmware versions (v2.06, Rev.2 v2.10, v2.13) via Ghidra disassembly and the following source files:
+
+- `SkyWalker1Control.h` -- defines modulation constants 0-9, none related to DVB-S2
+- `SkyWalker1CommonDef.h` -- device parameter structure uses `BDA_FEC_VITERBI` only
+- `SkyWalker1TunerFilter.cpp` -- explicitly rejects non-QPSK modulation types and non-Viterbi FEC
+- `SkyWalker1Control.cpp` -- hardcodes `ADV_MOD_DVB_QPSK` (value 0) in tune command byte 8
+
+**Specific evidence of no DVB-S2 awareness:**
+
+1. **Modulation enum caps at 9** (`SkyWalker1Control.h`, lines 64-74): The modulation constants are `ADV_MOD_DVB_QPSK` (0) through `ADV_MOD_DVB_BPSK` (9). No value 10+ exists for DVB-S2 modes.
+
+2. **Firmware dispatch table has exactly 10 entries** (`tuning-protocol-analysis.md`, Section 3.1): The jump table at CODE:0873 contains 20 bytes (10 entries x 2 bytes). Modulation values >= 10 are rejected by the bounds check at CODE:0866.
+
+3. **FEC type is hardcoded to Viterbi** (`SkyWalker1TunerFilter.cpp`, line 1070): `else if(ulNewInnerFecType == BDA_FEC_VITERBI)` -- only Viterbi is accepted; any other FEC type returns `STATUS_INVALID_PARAMETER`.
+
+4. **Tune command hardcodes DVB-S QPSK** (`SkyWalker1Control.cpp`, line 292): `ucCommand[8] = ADV_MOD_DVB_QPSK;` -- the Windows driver always sends modulation type 0 (DVB-S QPSK) regardless of what the application requests.
+
+5. **No LDPC/BCH code rate values** exist in any FEC lookup table. The firmware's XRAM tables at 0xE0B1, 0xE0B7, 0xE0BC, 0xE0BD, and 0xE0F9 contain only Viterbi rates (1/2 through 7/8), turbo rates, and DCII combined codes.
+
+6. **No DVB-S2-specific register addresses** appear in the I2C traffic. The BCM4500 is programmed exclusively through indirect registers 0xA6/0xA7/0xA8 with page 0x00 -- a protocol specific to the BCM4500. DVB-S2 demodulators like the STV0903 use entirely different register maps.
+
+---
+
+## 5. Could the GPIF Streaming Path Handle DVB-S2 Data Rates?
+
+**Yes -- the USB data path is not the bottleneck. The GPIF/USB 2.0 streaming architecture could handle DVB-S2 data rates if the demodulator supported them.**
+
+### Data Rate Analysis
+
+**DVB-S2 maximum useful bit rate** (from ETSI EN 302 307):
+- Highest configuration: 8PSK, rate 9/10, 30 Msps = ~72 Mbps raw, ~58 Mbps net after FEC
+- Typical HD transponder: 8PSK, rate 3/4, 27.5 Msps = ~44 Mbps net
+
+**GPIF/USB 2.0 throughput capacity:**
+- USB 2.0 High Speed bulk: 480 Mbps theoretical, ~35 MB/s (~280 Mbps) practical
+- GPIF engine: 48 MHz clock, 8-bit data path = 48 MB/s (384 Mbps) theoretical
+- EP2 FIFO: 4x buffer with AUTOIN, 7 URBs x 8KB on host side
+
+**Current DVB-S usage** (from `gpif-streaming-analysis.md`, Section 15):
+- "Transport stream rate: BCM4500 outputs at the satellite symbol rate (up to 30 Msps), but the effective byte rate depends on modulation and coding. USB 2.0 High Speed bulk bandwidth (480 Mbps theoretical, ~35 MB/s practical) is more than sufficient for DVB-S transport streams (typically 1-5 MB/s)."
+
+**Assessment**: Even at the theoretical maximum DVB-S2 data rate of ~58 Mbps (~7.25 MB/s), the USB 2.0 bulk streaming path has approximately 5x headroom. The GPIF engine configuration (IFCONFIG=0xEE, EP2FIFOCFG=0x0C, FLOWSTATEA with FSEN enabled) is identical across all firmware versions and provides a fully hardware-managed pipeline that would not require modification.
+
+The 8-bit parallel transport stream interface between the demodulator and FX2 is also sufficient -- DVB-S2 uses the same MPEG-TS output format (188-byte packets) as DVB-S. The GPIF waveform and AUTOIN configuration would work unchanged.
+
+**However**, this is a moot point. The bottleneck is the demodulator silicon, not the data path. Even if you physically replaced the BCM4500 with a DVB-S2-capable chip, you would need to rewrite the entire FX2 firmware (I2C register protocol, tuning sequence, modulation dispatch, FEC configuration) since every DVB-S2 demodulator uses a completely different register interface.
+
+---
+
+## Summary
+
+| Question | Answer |
+|----------|--------|
+| Is DVB-S2 a hardware or firmware limitation? | **Hardware** -- the BCM4500 has no LDPC/BCH decoder logic |
+| Could a firmware update add DVB-S2? | **No** -- LDPC decoding requires dedicated silicon |
+| Which Broadcom chip first added LDPC? | **BCM4501** (2006), followed by BCM4505/BCM4506 (2007) |
+| Any DVB-S2 hints in firmware/driver? | **None** -- zero references to LDPC, BCH, or DVB-S2 |
+| Is the USB data path a bottleneck? | **No** -- USB 2.0 bulk has ~5x headroom for DVB-S2 rates |
+| What did Genpix do for DVB-S2? | Released SkyWalker-3 with a different demodulator (likely STV0903) |
+| What was lost in the transition? | Turbo-FEC support (proprietary to Broadcom/EchoStar) |
+
+---
+
+## Sources
+
+### Datasheets and Product Pages
+- [BCM4500 Datasheet (DatasheetQ)](https://html.datasheetq.com/pdf-html/885700/Broadcom/2page/BCM4500.html)
+- [BCM4500 Datasheet (Elcodis)](https://elcodis.com/parts/5786421/BCM4500.html)
+- [BCM4500 Datasheet (AllDatasheet)](https://www.alldatasheet.com/datasheet-pdf/pdf/85246/BOARDCOM/BCM4500.html)
+- [BCM4501 Product Page (Broadcom)](https://www.broadcom.com/products/broadband/set-top-box/bcm4501)
+- [BCM4501 (EDN)](https://www.edn.com/bcm4501-dual-dvb-s2-advanced-modulation-satellite-receiver/)
+- [BCM4505 Product Page (Broadcom)](https://www.broadcom.com/products/broadband/set-top-box/bcm4505)
+- [BCM4506 Product Page (Broadcom)](https://www.broadcom.com/products/broadband/set-top-box/bcm4506)
+- [BCM4505/BCM4506 Announcement (RTTNews)](https://www.rttnews.com/380136/broadcom-launches-bcm4505-and-bcm4506-two-fully-integrated-single-chip-single-and-dual-channel-multi-format-satellite-receivers-quick-facts.aspx)
+
+### Genpix Products
+- [Genpix SkyWalker-3 Specifications](https://www.genpix-electronics.com/what-is-skywalker-3.html)
+- [Genpix Official Site](https://www.genpix-electronics.com/index.php?act=viewDoc&docId=9)
+
+### Community and Technical Discussions
+- [LinuxTV mailing list: BCM4500 and DVB-S2 distinction](https://www.mail-archive.com/linux-dvb@linuxtv.org/msg24808.html)
+- [SatelliteGuys: Turbo 8PSK card reverse engineering](https://www.satelliteguys.us/xen/threads/another-turbo-8psk-card.246879/)
+- [SatelliteGuys: Genpix SkyWalker-1 discussion](https://www.satelliteguys.us/xen/threads/genpix-skywalker-1.214196/)
+
+### Reverse Engineering Analysis (This Project)
+- `skywalker1-hardware-reference.md` -- Sections 1, 6, 7: Overview, tuning protocol, BCM4500 interface
+- `tuning-protocol-analysis.md` -- Section 3: Modulation dispatch table, FEC lookup tables
+- `gpif-streaming-analysis.md` -- Sections 13-15: GPIF throughput and data path analysis
+- `rev2-deep-analysis.md` -- Complete Rev.2 function inventory
+- `SkyWalker1Control.h` -- Modulation mode constants (lines 63-74), FEC/command definitions
+- `SkyWalker1TunerFilter.cpp` -- SetInnerFecType() Viterbi-only restriction (lines 1058-1086)
+- `SkyWalker1Control.cpp` -- TuneDevice() hardcoded ADV_MOD_DVB_QPSK (line 292)
diff --git a/firmware-analysis-v206-vs-v213.md b/firmware-analysis-v206-vs-v213.md
index 69b5ead..7e5b271 100644
--- a/firmware-analysis-v206-vs-v213.md
+++ b/firmware-analysis-v206-vs-v213.md
@@ -1,571 +1,571 @@
-# Genpix SkyWalker-1 FX2 Firmware Comparative Analysis: v2.06 vs v2.13 FW1
-
-## Executive Summary
-
-v2.13 is a significant evolution of the v2.06 firmware with 21 additional functions (82 vs 61). The key changes are:
-
-1. **Three new vendor commands** (0x99, 0x9A, 0x9C) for LNB/tuner control
-2. **Restructured INT0 handler** with active satellite front-end polling
-3. **I2C-based initialization** with retry logic for the satellite demodulator
-4. **Version-aware code paths** (hardware revision detection via descriptor byte)
-5. **Refactored DiSEqC GPIO pin assignment** (data pin moved from P0.7 to P0.0, same bit-bang algorithm)
-6. **Simplified BCM4500 status polling** (consolidated from 3 register reads to 1)
-
----
-
-## 1. Vendor Command Dispatch Table Comparison
-
-Both versions use the same two-stage USB control request dispatch:
-
-- **Stage 1** (`FUN_CODE_032a` / `FUN_CODE_034e`): Handles standard USB requests (bRequest 0x00-0x0B) via a 12-entry jump table at CODE:033B / CODE:035F. These handle GET_STATUS, CLEAR_FEATURE, SET_FEATURE, SET_ADDRESS, GET_DESCRIPTOR, SET_DESCRIPTOR, GET_CONFIGURATION, SET_CONFIGURATION, GET_INTERFACE, SET_INTERFACE, SYNCH_FRAME, and FW_VERSION_READ (0x0B).
-
-- **Stage 2** (`FUN_CODE_0056`, identical in both versions): Handles vendor requests (bmRequestType bit 6 set, bRequest 0x80-0x9D) via a 30-entry jump table at CODE:0076. Range check: `(bRequest + 0x80) < 0x1E`, dispatching to `JMP @A+DPTR` at `0x76 + (bRequest - 0x80) * 2`.
-
-### Vendor Command Jump Table (0x80-0x9D)
-
-| bRequest | Name | v2.06 Target | v2.13 Target | Status |
-|----------|------|-------------|-------------|--------|
-| 0x80 | GET_8PSK_CONFIG | 0x00B2 | 0x00B2 | **Both**: Read config byte to EP0BUF (v2.06: IRAM 0x6D, v2.13: IRAM 0x4F) |
-| 0x81 | SET_8PSK_CONFIG | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** - not implemented in either |
-| 0x82 | (reserved) | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** |
-| 0x83 | I2C_WRITE | 0x00F1 | 0x00F1 | **Both**: Same I2C write handler |
-| 0x84 | I2C_READ | 0x0102 | 0x0102 | **Both**: Same I2C read handler |
-| 0x85 | ARM_TRANSFER | 0x0110 | 0x0110 | **Both**: Same ARM transfer handler |
-| 0x86 | TUNE_8PSK | 0x012E | 0x012E | **Both**: Same tuning handler |
-| 0x87 | GET_SIGNAL_STRENGTH | 0x0140 | 0x0162 | **CHANGED** - see section below |
-| 0x88 | LOAD_BCM4500 | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** - BCM4500 loading via different mechanism |
-| 0x89 | BOOT_8PSK | 0x00C4 | 0x00C4 | **Both**: Same boot handler |
-| 0x8A | START_INTERSIL | 0x019C | 0x01BE | **Relocated** but functionally similar |
-| 0x8B | SET_LNB_VOLTAGE | 0x01CB | 0x01ED | **Relocated** but functionally similar |
-| 0x8C | SET_22KHZ_TONE | 0x01DD | 0x01FF | **Relocated** but functionally similar |
-| 0x8D | SEND_DISEQC_COMMAND | 0x01EF | 0x0211 | **CHANGED** - different DiSEqC implementation |
-| 0x8E | SET_DVB_MODE | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** |
-| 0x8F | (unknown) | 0x01FC | 0x021E | Both: Similar read-back function |
-| 0x90 | GET_SIGNAL_LOCK | 0x020B | 0x022D | **Relocated** but functionally similar |
-| 0x91 | (unknown) | 0x022C | 0x024E | Both: I2C read-back |
-| 0x92 | (unknown) | 0x024A | 0x026C | Both: I2C read-back |
-| 0x93 | GET_SERIAL_NUMBER | 0x026F | 0x0293 | **Relocated** but functionally similar |
-| 0x94 | (unknown) | 0x01B9 | 0x01DB | Both: LNB-related |
-| 0x95 | (unknown) | 0x02DF | 0x0303 | Both: Read-back function |
-| 0x96 | (unknown) | 0x02B4 | 0x02D8 | Both: Similar handler |
-| 0x97 | (unknown) | 0x02C1 | 0x02E5 | Both: Similar handler |
-| 0x98 | (unknown) | 0x02CB | 0x02EF | Both: Similar handler |
-| 0x99 | **NEW: GET_DEMOD_STATUS** | 0x0326 (STALL) | 0x0317 | **ADDED in v2.13** |
-| 0x9A | **NEW: INIT_DEMOD** | 0x0326 (STALL) | 0x0140 | **ADDED in v2.13** |
-| 0x9B | (reserved) | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** |
-| 0x9C | **NEW: DELAY_COMMAND** | 0x0326 (STALL) | 0x032B | **ADDED in v2.13** |
-| 0x9D | SET_MODE_FLAG | 0x02FA | 0x033A | **CHANGED** - different implementation |
-
-### Commands Added in v2.13
-
-**0x99 - GET_DEMOD_STATUS (new read command)**
-```
-LCALL FUN_CODE_2421 ; calls FUN_CODE_2239(0x3F, 0xF9)
- ; -> I2C read from device 0x3F, register 0xF9
-MOV EP0BUF[0], R7 ; return I2C read result
-EP0BCL = 1 ; send 1 byte back
-```
-Reads demodulator register 0xF9 via I2C (device address 0x3F) and returns the value to the host. This is a status/diagnostics register read for the satellite demodulator IC.
-
-**0x9A - INIT_DEMOD (new control command)**
-```
-LCALL 0x231E ; EP0 flush/prepare
-if (config_flags.0 == 1) { ; check if demodulator is present
- counter = 0;
- while (counter < 3) {
- LCALL FUN_CODE_1977 ; initialization step
- if (success) break;
- counter++;
- }
-}
-EP0BCL = 0 ; no data returned
-```
-Performs up to 3 attempts to initialize the demodulator, but only if the demodulator-present flag (bit 0 of DAT_INTMEM_4F) is set. This provides host-triggered re-initialization capability.
-
-**0x9C - DELAY_COMMAND (new control command)**
-```
-R7 = wValue ; delay parameter from USB SETUP packet
-LCALL FUN_CODE_1ac6 ; tuning/acquisition delay function
-EP0BCL = 0 ; no data returned
-```
-Calls FUN_CODE_1ac6 with the wValue parameter from the USB SETUP packet. FUN_CODE_1ac6 performs an I2C-based tuning acquisition sequence: it reads demod register 0xF9, writes control values to registers 0xF8 and 0xF9, then polls register 0xF9 up to 40 times (0x28) waiting for bit 0 to be set (lock acquired). If lock fails, it calls FUN_CODE_1e3c which performs a full demodulator reset sequence.
-
-### Commands Removed from v2.13
-None were removed -- all commands that were STALL in v2.06 remain STALL in v2.13.
-
-### Changed Command Implementations
-
-**0x87 - GET_SIGNAL_STRENGTH (modified)**
-- v2.06 at 0x0140: Checks DAT_INTMEM_6D bit 0 (demod active), reads three I2C status registers (0xA2, 0xA8, 0xA4) to compute signal quality, loops up to 6 iterations polling for demod readiness
-- v2.13 at 0x0162: Checks DAT_INTMEM_4F bit 0 (demod active), reads I2C but uses different function call chain (FUN_CODE_1278 vs FUN_CODE_0c97). Same overall logic with relocated internal variables.
-
-**0x8D - SEND_DISEQC_COMMAND (GPIO pin reassignment)**
-- v2.06: `LCALL 0x23e0; LCALL 0x1e41` -- GPIO bit-bang DiSEqC via FUN_CODE_2098, data on **P0.7**, carrier on P0.3
-- v2.13: `LCALL 0x231e; LCALL FUN_CODE_0dbc` -- GPIO bit-bang DiSEqC via FUN_CODE_2060, data on **P0.0**, carrier on P0.3
-
-Both versions use the identical algorithm:
- 1. Read wLength (0xE6BE) as message byte count
- 2. Clear P0.3 (disable 22kHz carrier)
- 3. Delay 15 ticks via delay function (7.5ms settling time)
- 4. If message bytes present: iterate through EP0BUF, sending each byte via Manchester-encoded bit-bang (8 data bits + odd parity, 3 Timer2 ticks per bit)
- 5. If wValue == 0 and no bytes: tone burst A (25 Timer2 ticks = 12.5ms)
- 6. If wValue != 0 and no bytes: tone burst B via byte transmit with 0xFF pattern
-
-**CORRECTION**: Earlier analysis incorrectly identified v2.13 as using "I2C-based DiSEqC." Deep decompilation of the sub-functions (FUN_CODE_2060, FUN_CODE_22f3, FUN_CODE_22b0) reveals they are GPIO bit-bang implementations identical in algorithm to v2.06's FUN_CODE_2098 and FUN_CODE_2372. The only change is the data pin assignment (P0.7 -> P0.0), reflecting a different PCB layout.
-
-**0x9D - SET_MODE_FLAG (different logic)**
-- v2.06: Reads byte at descriptor_base + 10, checks if value is 4, 5, or 6, and conditionally sets bit flag 0x06 based on wValue - 1
-- v2.13: Simply checks if wValue != 0, and if so calls FUN_CODE_21d1 which performs a conditional demodulator reset (calls FUN_CODE_1e3c if `_1_4` flag isn't already set, then writes I2C control registers 0xFC on both device 0x7F and 0x3F)
-
----
-
-## 2. Key Function Correspondence
-
-| v2.06 Function | v2.13 Function | Role |
-|---------------|---------------|------|
-| `main` (0x188D) | `main_entry` (0x170D) | RESET vector - clears IRAM, processes init table, jumps to init |
-| `FUN_CODE_09a7` (0x09A7) | `FUN_CODE_0800` (0x0800) | Main init + main loop |
-| `FUN_CODE_13c3` (0x13C3) | `FUN_CODE_11ab` (0x11AB) | USB/peripheral descriptor setup |
-| `FUN_CODE_032a` (0x032A) | `FUN_CODE_034e` (0x034E) | Standard USB request handler |
-| `FUN_CODE_0056` (0x0056) | `FUN_CODE_0056` (0x0056) | Vendor request dispatcher (identical code) |
-| `FUN_CODE_2297` (0x2297) | `FUN_CODE_21ec` (0x21EC) | Main loop poll (USB IRQ processing) |
-| `FUN_CODE_21ed` (0x21ED) | `FUN_CODE_2189` (0x2189) | EP2CS setup + PCON idle |
-| `FUN_CODE_211d` (0x211D) | `FUN_CODE_20b9` (0x20B9) | CPUCS reset pulse (EP2 management) |
-| `FUN_CODE_2174` (0x2174) | `FUN_CODE_2110` (0x2110) | USB descriptor type walker (identical code) |
-| `FUN_CODE_1919` (0x1919) | `FUN_CODE_1800` (0x1800) | GPIF/FIFO management (identical logic) |
-| `FUN_CODE_1d4f` (0x1D4F) | -- | v2.06 demod init (GPIO-based, complex) |
-| -- | `FUN_CODE_1d4b` (0x1D4B) | v2.13 demod init (I2C write 4 bytes to 0x7F/0xF0) |
-| `FUN_CODE_1da8` (0x1DA8) | -- | v2.06 I2C read with timeout (uses FUN_CODE_1556) |
-| -- | `FUN_CODE_0eea` (0x0EEA) | v2.13 I2C read with retry (20 attempts) |
-| `FUN_CODE_1dfb` (0x1DFB) | `FUN_CODE_14b9` (0x14B9) | Delay loop (clock-dependent timing) |
-| `FUN_CODE_1cf3` (0x1CF3) | `FUN_CODE_1c44` (0x1C44) | Configuration update function |
-| `FUN_CODE_12ea` (0x12EA) | `FUN_CODE_1000` (0x1000) | USB endpoint configuration |
-| `FUN_CODE_0ddd` (0x0DDD) | `FUN_CODE_0ca4` (0x0CA4) | BCM4500 firmware loader |
-| `FUN_CODE_2000` (0x2000) | `FUN_CODE_208d` (0x208D) | BCM4500 status polling |
-| `FUN_CODE_1556` (0x1556) | `FUN_CODE_0eea` (0x0EEA) | I2C multi-byte transfer |
-| `FUN_CODE_24d2` (0x24D2) | `FUN_CODE_243d` (0x243D) | SET_DVB_MODE config store |
-| `FUN_CODE_2419` (0x2419) | `FUN_CODE_2357` (0x2357) | GET config byte to EP0BUF |
-| `FUN_CODE_23cb` (0x23CB) | `FUN_CODE_2309` (0x2309) | Read descriptor byte to EP0BUF |
-| `FUN_CODE_1a0e` (0x1A0E) | -- | v2.06 serial number reader (EEPROM) |
-| `INT0_vec` (0x0003) | `INT0_vector` (0x0003) | INT0 interrupt handler (**significantly different**) |
-| -- | `FUN_CODE_2239` (0x2239) | v2.13 I2C single-byte read helper |
-| -- | `FUN_CODE_2031` (0x2031) | v2.13 USB reconnect function |
-| -- | `FUN_CODE_1799` (0x1799) | v2.13 demod checksum/signature verify |
-| -- | `FUN_CODE_1ca0` (0x1CA0) | v2.13 descriptor checksum verify |
-| -- | `FUN_CODE_1ac6` (0x1AC6) | v2.13 tuning acquisition sequence |
-| -- | `FUN_CODE_1e3c` (0x1E3C) | v2.13 demodulator full reset |
-| -- | `FUN_CODE_10d9` (0x10D9) | v2.13 demod status polling/init |
-| -- | `FUN_CODE_0dbc` (0x0DBC) | v2.13 DiSEqC GPIO bit-bang wrapper (data on P0.0) |
-
-### USB Descriptor Setup (FUN_CODE_13c3 vs FUN_CODE_11ab)
-
-Both functions are structurally identical:
-1. Disable USB disconnect (0xE605 bit 1 clear)
-2. Configure IFCONFIG (0xE600) for internal clock, 48MHz
-3. Set REVCTL (0xE601) to 0xCA
-4. Configure GPIFIDLECTL, PORTACFG
-5. Set PORT registers (P0, P3, IPL1)
-6. Configure GPIFCTLCFG, FIFORESET, FIFOPINPOLAR
-7. Configure Timer2 (RCAP2H=0xF8, RCAP2L=0x2F -> ~2ms period at 48MHz/12)
-8. Initialize subsystem modules
-
-Key difference: v2.13 calls `INT0_vector()` (the INT0 handler) during initialization as a probing step. This runs the demodulator availability check during USB setup, before enabling interrupts. v2.06 does not do this.
-
-Descriptor pointer offsets:
-- v2.06: BANK1_R4:R5 = 0x1200 (descriptor base)
-- v2.13: BANK1_R4:R5 = 0x0E00 (descriptor base, lower due to code restructuring)
-
----
-
-## 3. Structural Differences
-
-### 3.1 v2.13 Retry Loops (FUN_CODE_1799 and FUN_CODE_1ca0)
-
-In the main init function `FUN_CODE_0800`, v2.13 has:
-
-```c
-// Retry loop 1: FUN_CODE_1799 - demodulator signature verification
-DAT_INTMEM_36 = 0x14; // 20 attempts
-while (DAT_INTMEM_36 != 0 && FUN_CODE_1799() fails) {
- DAT_INTMEM_36--;
-}
-if (DAT_INTMEM_36 == 0) {
- FUN_CODE_1ac6(100); // tuning acquisition with 100ms delay
-}
-
-// Retry loop 2: FUN_CODE_1ca0 - descriptor checksum verification
-DAT_INTMEM_36 = 0x14; // 20 attempts
-while (DAT_INTMEM_36 != 0 && FUN_CODE_1ca0() fails) {
- DAT_INTMEM_36--;
-}
-if (DAT_INTMEM_36 == 0) {
- FUN_CODE_1ac6(100); // tuning acquisition with 100ms delay
-}
-```
-
-**FUN_CODE_1799 - Demodulator Signature Verification:**
-1. Calls FUN_CODE_1d4b() which writes 4 bytes via I2C to device 0x7F, register 0xF0 (demodulator control)
-2. Saves parameters DAT_INTMEM_39:3A
-3. Checks if parameters match 0x021C (known good value) - returns early if match
-4. Reads 5 I2C bytes via FUN_CODE_0718, each at register 0x0A offset (stepping by 2)
-5. Subtracts 0x30 ('0') from each byte (ASCII to binary conversion)
-6. Sums the values and compares sum to the saved parameters
-7. Returns success (carry set) if checksum matches
-
-This verifies the demodulator responds correctly with the expected identification pattern. The ASCII-to-binary conversion suggests the demod returns a readable version string at register 0x0A.
-
-**FUN_CODE_1ca0 - Descriptor Checksum Verification:**
-1. Iterates bytes 6 through 0x29 (36 bytes) of the BANK2_R6:R7 descriptor block
-2. Computes running sum, compares against expected value 0x0706
-3. If first block passes, iterates bytes 0x2C through 0x4F (36 bytes) of same block
-4. Computes second running sum, compares against expected value 0x0686
-5. Returns success only if both checksums match
-
-This validates the integrity of a 2-block descriptor/configuration structure (possibly EEPROM-loaded calibration data).
-
-**v2.06 equivalent:** v2.06 does NOT have these retry loops. It calls `FUN_CODE_1a0e` (serial number/EEPROM reader) directly without verification, then proceeds immediately. There is no signature check or checksum validation.
-
-### 3.2 Version Byte Check (Hardware Revision Detection)
-
-After the retry loops, v2.13 performs:
-
-```c
-// Read byte at descriptor_base + 10
-byte version_byte = *(BANK1_R4:R5 + 10); // 0x0E0A
-if (version_byte == 0x03) {
- bVar4 = 0x80; // flag = set
-} else {
- bVar4 = 0; // flag = clear
-}
-_1_3 = bVar4 >> 7; // store as bit flag _1_3
-```
-
-This reads byte offset 10 from the USB descriptor base address. Offset 10 in a USB device descriptor is `bMaxPacketSize0` in standard USB, but since this is a custom descriptor area, it likely encodes a hardware revision. The value 0x03 sets bit flag `_1_3`, creating a hardware-revision-aware code path.
-
-**Impact:** The `_1_3` flag is used elsewhere in v2.13 to conditionally execute different initialization sequences, supporting multiple hardware revisions of the SkyWalker-1 board.
-
-### 3.3 FUN_CODE_2031 - USB Reconnect Before Main Loop
-
-```c
-void FUN_CODE_2031(void) {
- if (_0_0 == 0) {
- CPUCS |= 0x08; // Set CPUCS.3 (8051 reset bit? Or re-enumerate)
- } else {
- CPUCS |= 0x0A; // Set CPUCS.3 + CPUCS.1
- }
- FUN_CODE_14b9(5, 0xDC); // Delay ~1500 cycles
- EPIRQ = 0xFF; // Clear all endpoint interrupts
- USBIRQ = 0xFF; // Clear all USB interrupts
- DAT_SFR_91 &= 0xEF; // Clear EXIF.4 (USB interrupt flag)
- CPUCS &= 0xF7; // Clear CPUCS.3
-}
-```
-
-This performs a controlled USB re-enumeration by pulsing CPUCS.3, then clearing all pending USB/endpoint interrupts. The conditional on `_0_0` adds CPUCS.1 when the flag is set (possibly switching between 12MHz and 48MHz operation).
-
-**v2.06 equivalent:** In v2.06, this exact same logic exists as `INT0_vec` (the INT0 interrupt handler at 0x0003). The critical difference is that in v2.06 this code runs as an interrupt handler, while in v2.13 it's called as a normal function (`FUN_CODE_2031`) before the main loop starts, AND the INT0 vector is repurposed for demodulator polling (see section 4).
-
----
-
-## 4. INT0 Handler Difference
-
-### v2.06 INT0 (CODE:0003) - USB Re-enumeration
-
-```c
-void INT0_vec(void) {
- if (_0_7 == 0) {
- CPUCS |= 0x08; // CPUCS bit 3
- } else {
- CPUCS |= 0x0A; // CPUCS bits 3+1
- }
- FUN_CODE_1dfb(5, 0xDC); // Delay
- EPIRQ = 0xFF; // Clear endpoint IRQs
- USBIRQ = 0xFF; // Clear USB IRQs
- DAT_SFR_91 &= 0xEF; // Clear external interrupt flag
- CPUCS &= 0xF7; // Clear CPUCS bit 3
-}
-```
-
-Simple USB reconnect/re-enumeration handler. Pulses CPUCS.3, clears all pending interrupts.
-
-### v2.13 INT0 (CODE:0003) - Demodulator Availability Polling
-
-```c
-void INT0_vector(void) {
- for (DAT_INTMEM_37 = 0x28; DAT_INTMEM_37 != 0; DAT_INTMEM_37--) {
- // Read I2C device 0x7F (demod A), checking for response
- byte result = FUN_CODE_2239(0x7F); // I2C read from 0x7F
- if (result != 0x01) {
- // Try I2C device 0x3F (demod B)
- result = FUN_CODE_2239(0x3F); // I2C read from 0x3F
- if (result != 0x01) break; // Neither responded normally
- }
- }
- _1_4 = (DAT_INTMEM_37 == 0); // Set flag if loop exhausted (no demod found)
-}
-```
-
-This is a complete replacement of INT0's purpose. Instead of USB re-enumeration, INT0 now polls two I2C devices (0x7F and 0x3F) up to 40 times (0x28). These are two possible addresses for the satellite demodulator IC.
-
-**FUN_CODE_2239 decompiled:**
-```c
-undefined1 FUN_CODE_2239(byte device_addr) {
- DAT_INTMEM_48 = 0xE1; // buffer address high
- DAT_INTMEM_49 = 0; // buffer address low
- FUN_CODE_0eea(1, device_addr, 0x51); // I2C read 1 byte from device
- return DAT_EXTMEM_e100; // return the read byte
-}
-```
-
-The function performs an I2C single-byte read from the specified device address, using address 0x51 as a parameter (likely selecting a specific I2C bus or mode via the FX2's auxiliary I2C controller at 0xE678). It stores the result at 0xE100 (XRAM buffer).
-
-**Behavioral meaning:** The flag `_1_4` is set to 1 if neither demodulator responded after 40 attempts - indicating no demodulator hardware is present. This flag is later checked by:
-- `FUN_CODE_21d1` (command 0x9D handler) - skips demodulator reset if `_1_4 != 1`
-- Various initialization paths to avoid hanging on missing hardware
-
-**Why this matters:** v2.06 assumes the demodulator is always present. v2.13 can detect and gracefully handle boards where the demodulator is absent or unresponsive, making it more robust for manufacturing QC and field failures.
-
----
-
-## 5. What Can v2.13 Do That v2.06 Cannot?
-
-### 5.1 Demodulator Hardware Detection
-v2.13 probes two I2C addresses (0x7F, 0x3F) at startup to determine which demodulator variant is installed, or if none is present. v2.06 blindly assumes the hardware configuration.
-
-### 5.2 Host-Initiated Demodulator Re-initialization (Command 0x9A)
-The host can trigger a demodulator re-initialization via USB vendor command 0x9A, with up to 3 retry attempts. v2.06 has no mechanism for the host to request re-initialization.
-
-### 5.3 Demodulator Status Read (Command 0x99)
-Direct I2C register read of demodulator register 0xF9, returned to host. This enables diagnostic/monitoring software to check demodulator status without going through the full signal quality pipeline.
-
-### 5.4 Host-Controlled Tuning Delay (Command 0x9C)
-Allows the host to invoke the tuning acquisition sequence with a configurable delay parameter. In v2.06, the tuning timing is entirely firmware-controlled with no host influence.
-
-### 5.5 DiSEqC GPIO Pin Reassignment
-All firmware versions use the same GPIO bit-bang algorithm for DiSEqC signaling. The only change is the data pin assignment per PCB revision:
-
-| Version | Data Pin | Carrier Pin | Byte Transmit | Bit Symbol | Timer Tick |
-|---------|----------|-------------|--------------|------------|------------|
-| v2.06 | **P0.7** | P0.3 | 0x2098 | 0x23B5 | 0x24C6 |
-| Rev.2 v2.10 | **P0.4** | P0.3 | FUN_CODE_07d1 | FUN_CODE_213c | FUN_CODE_225f |
-| v2.13 FW1 | **P0.0** | P0.3 | FUN_CODE_2060 | FUN_CODE_22f3 | func_0x2431 |
-
-The algorithm is identical across all versions: Manchester-encoded bit-bang with Timer2-based timing, odd parity per byte, and 25-tick tone bursts for mini-commands.
-
-### 5.6 Firmware/Descriptor Integrity Verification
-v2.13 validates demodulator identification (ASCII version string checksum) and descriptor block integrity (two 36-byte checksums) before proceeding. If verification fails after 20 attempts, it falls back to a recovery sequence. v2.06 does no integrity checking.
-
-### 5.7 Hardware Revision Awareness
-The version byte check (descriptor offset 10, value 0x03) creates conditional code paths allowing a single firmware image to support multiple SkyWalker-1 hardware revisions. v2.06 has a single code path for one hardware revision.
-
-### 5.8 Simplified BCM4500 Status Polling
-v2.06's `FUN_CODE_2000` polls three separate BCM4500 registers (0xA2, 0xA8, 0xA4 via I2C) to determine demodulator readiness. v2.13's `FUN_CODE_208d` polls only one register (0xA4), suggesting either the demodulator firmware was updated to consolidate status, or the additional checks were found to be redundant.
-
-### 5.9 Conditional Demodulator Reset (Command 0x9D)
-v2.13's 0x9D handler can trigger a full demodulator reset sequence (FUN_CODE_1e3c -> register writes to 0x18 bus) controlled by the host via wValue. This is useful for error recovery without full device re-enumeration.
-
----
-
-## 6. Architecture Summary
-
-| Aspect | v2.06 | v2.13 |
-|--------|-------|-------|
-| Total functions | 61 | 82 (+21) |
-| RESET vector | 0x188D | 0x170D |
-| Stack pointer | 0x72 | 0x50 |
-| Init data table | CODE:0B46 | CODE:0B88 |
-| Descriptor base | 0x1200 | 0x0E00 |
-| Config byte (IRAM) | 0x6D | 0x4F |
-| INT0 purpose | USB re-enumerate | Demod probe |
-| DiSEqC data pin | P0.7 (GPIO bit-bang) | P0.0 (GPIO bit-bang) |
-| Demod init | Direct, no retry | 20-attempt retry |
-| Integrity checks | None | Checksum verification |
-| HW revision support | Single | Multi-revision (flag _1_3) |
-| New vendor cmds | -- | 0x99, 0x9A, 0x9C |
-
----
-
-## 7. DiSEqC Timing Chain Analysis
-
-### 7.1 Timer2 Configuration (Identical Across All Versions)
-
-All firmware versions configure Timer2 identically during USB descriptor setup:
-
-```
-T2CON = 0x04 ; Auto-reload mode, internal clock, TR2=1 (running)
-RCAP2H = 0xF8 ; Reload high byte
-RCAP2L = 0x2F ; Reload low byte -> RCAP2 = 0xF82F = 63535
-CKCON = 0x00 ; Default (T2M=0 -> Timer2 clock = CLKOUT/12)
-```
-
-**Timer2 Clock Derivation:**
-```
-FX2 master clock = 48 MHz
-CKCON.T2M = 0 -> Timer2 clock = 48 MHz / 12 = 4 MHz
-Count per overflow = 65536 - 63535 = 2001
-Tick period = 2001 / 4,000,000 = 500.25 us ~ 500 us
-Tick frequency ~ 2.0 kHz
-```
-
-Timer2 runs continuously from power-on and is never stopped or reconfigured. It serves as a stable 500 us timebase for all DiSEqC operations.
-
-### 7.2 DiSEqC Signal Architecture
-
-```
-FX2 Firmware External Hardware Coax Cable
-+------------------+ +--------------------+ +------------------+
-| | | | | |
-| P0.3 (carrier) |---->| 22 kHz oscillator |---->| LNB power line |
-| (enable/disable) | | (gated by P0.3) | | (13V/18V + tone) |
-| | | | | |
-| P0.x (data bit) | | (internal to FX2 | | |
-| (firmware only) | | firmware logic) | | |
-+------------------+ +--------------------+ +------------------+
-```
-
-The firmware does NOT generate the 22 kHz carrier directly. P0.3 gates an external
-22 kHz oscillator circuit on the PCB. The data pin (P0.7/P0.4/P0.0 depending on
-version) is used only internally by the firmware to control the Manchester encoding
-logic -- it tells the bit-symbol function whether to cut the carrier short or leave
-it on for the full period.
-
-### 7.3 Manchester Encoding (DiSEqC Bit Symbol)
-
-Each DiSEqC bit consists of 3 Timer2 ticks (3 x 500 us = 1.5 ms):
-
-**Data '0' (2/3 tone, 1/3 silence):**
-```
- Tick 1 Tick 2 Tick 3
- (500 us) (500 us) (500 us)
-P0.3: _____|========|========|________|
- ^tone ON ^tone OFF
- (setup gap) (1.0 ms carrier) (0.5 ms silence)
-```
-
-**Data '1' (1/3 tone, 2/3 silence):**
-```
- Tick 1 Tick 2 Tick 3
- (500 us) (500 us) (500 us)
-P0.3: _____|========|________|________|
- ^tone ON ^tone OFF early
- (setup gap) (0.5 ms carrier) (1.0 ms silence)
-```
-
-**Implementation (decompiled from Rev.2 FUN_CODE_213c):**
-```c
-void diseqc_bit_symbol(void) {
- wait_TF2(); // Tick 1: inter-bit gap (500 us)
- P0 |= 0x08; // P0.3 = 1 -> 22 kHz carrier ON
- wait_TF2(); // Tick 2: carrier period (500 us)
- if (data_pin != 0) { // If data = '1':
- P0 &= 0xF7; // P0.3 = 0 -> carrier OFF (short pulse)
- }
- wait_TF2(); // Tick 3: final period (500 us)
- P0 &= 0xF7; // P0.3 = 0 -> carrier always OFF at end
-}
-```
-
-### 7.4 Byte Transmission (8 Data Bits + Odd Parity)
-
-Each DiSEqC byte is 9 bits: 8 data (MSB first) + 1 parity (odd).
-
-**Implementation (decompiled from Rev.2 FUN_CODE_07d1):**
-```c
-void diseqc_send_byte(char first_byte, byte data) {
- byte ones_count = 0;
- if (first_byte == 0) TF2 = 0; // Sync timer on first byte
-
- for (char i = 8; i > 0; i--) { // 8 bits, MSB first
- if (data & 0x80) { // Test MSB
- data_pin = 1; // Set data = '1'
- diseqc_bit_symbol(); // Transmit '1' symbol
- ones_count++;
- } else {
- data_pin = 0; // Set data = '0'
- diseqc_bit_symbol(); // Transmit '0' symbol
- }
- data <<= 1; // Next bit
- }
-
- data_pin = ~ones_count & 1; // Odd parity: '1' if even count
- diseqc_bit_symbol(); // Transmit parity bit
-}
-```
-
-**Timing per byte:** 9 bits x 1.5 ms = 13.5 ms
-
-### 7.5 Tone Burst (Mini DiSEqC Command)
-
-For legacy 2-way satellite switches, a simple tone burst is used instead of a
-full DiSEqC message. The burst is 25 Timer2 ticks of continuous carrier:
-
-```c
-void tone_burst_A(void) {
- TF2 = 0; // Sync timer
- wait_TF2(); // One tick gap
- P0 |= 0x08; // P0.3 = 1 -> carrier ON
- for (char i = 25; i > 0; i--) {
- wait_TF2(); // 25 x 500 us = 12.5 ms
- }
- P0 &= 0xF7; // P0.3 = 0 -> carrier OFF
-}
-```
-
-**Burst duration:** 25 x 500 us = 12.5 ms (matches DiSEqC spec)
-
-### 7.6 Timer Tick Wait (TF2 Polling)
-
-The lowest-level timing primitive is a busy-wait on Timer2 overflow:
-
-```c
-void wait_TF2(void) {
- while (TF2 == 0) {} // Poll Timer2 overflow flag
- TF2 = 0; // Clear flag for next tick
-}
-```
-
-This is identical across all versions (v2.06: 0x24C6, Rev.2: FUN_CODE_225f,
-v2.13: func_0x2431). Timer2 overflows every 500.25 us, providing the fundamental
-DiSEqC timebase.
-
-### 7.7 CPU Clock Compensation (Delay Function)
-
-The delay function used before DiSEqC transmission adjusts for CPU clock speed:
-
-```c
-void delay(byte high, byte low) {
- byte clkspd = CPUCS & 0x18; // CPUCS[4:3] = clock speed bits
- if (clkspd == 0x00) { // 12 MHz: halve the count
- // Adjust high:low /= 2
- } else if (clkspd == 0x10) { // 48 MHz: double the count
- // Adjust high:low *= 2
- }
- // 24 MHz (0x08): use count as-is
- while (high:low > 0) {
- wait_TF2();
- high:low--;
- }
-}
-```
-
-The pre-DiSEqC delay call is `delay(0, 0x0F)` = 15 ticks x 500 us = 7.5 ms.
-This allows the LNB voltage to stabilize before DiSEqC signaling begins.
-
-### 7.8 Complete DiSEqC Timing Summary
-
-| Parameter | Value | Source |
-|-----------|-------|--------|
-| Timer2 clock | 4 MHz (48 MHz / 12) | CKCON default, T2M=0 |
-| Timer2 reload | 0xF82F | RCAP2H:RCAP2L |
-| Tick period | 500.25 us | (65536 - 63535) / 4 MHz |
-| Bit period | 1.5 ms (3 ticks) | DiSEqC Manchester encoding |
-| Byte period | 13.5 ms (9 bits) | 8 data + 1 parity |
-| Tone burst | 12.5 ms (25 ticks) | Mini-command A/B |
-| Pre-TX delay | 7.5 ms (15 ticks) | Voltage settling |
-| Data '0' | 1.0 ms tone + 0.5 ms silence | 2/3 duty cycle |
-| Data '1' | 0.5 ms tone + 1.0 ms silence | 1/3 duty cycle |
-| Carrier frequency | 22 kHz (external oscillator) | Gated by P0.3 |
-| Carrier enable | P0.3 | All versions |
-| Data pin (v2.06) | P0.7 | PCB revision A |
-| Data pin (Rev.2) | P0.4 | PCB revision B |
-| Data pin (v2.13) | P0.0 | PCB revision C |
+# Genpix SkyWalker-1 FX2 Firmware Comparative Analysis: v2.06 vs v2.13 FW1
+
+## Executive Summary
+
+v2.13 is a significant evolution of the v2.06 firmware with 21 additional functions (82 vs 61). The key changes are:
+
+1. **Three new vendor commands** (0x99, 0x9A, 0x9C) for LNB/tuner control
+2. **Restructured INT0 handler** with active satellite front-end polling
+3. **I2C-based initialization** with retry logic for the satellite demodulator
+4. **Version-aware code paths** (hardware revision detection via descriptor byte)
+5. **Refactored DiSEqC GPIO pin assignment** (data pin moved from P0.7 to P0.0, same bit-bang algorithm)
+6. **Simplified BCM4500 status polling** (consolidated from 3 register reads to 1)
+
+---
+
+## 1. Vendor Command Dispatch Table Comparison
+
+Both versions use the same two-stage USB control request dispatch:
+
+- **Stage 1** (`FUN_CODE_032a` / `FUN_CODE_034e`): Handles standard USB requests (bRequest 0x00-0x0B) via a 12-entry jump table at CODE:033B / CODE:035F. These handle GET_STATUS, CLEAR_FEATURE, SET_FEATURE, SET_ADDRESS, GET_DESCRIPTOR, SET_DESCRIPTOR, GET_CONFIGURATION, SET_CONFIGURATION, GET_INTERFACE, SET_INTERFACE, SYNCH_FRAME, and FW_VERSION_READ (0x0B).
+
+- **Stage 2** (`FUN_CODE_0056`, identical in both versions): Handles vendor requests (bmRequestType bit 6 set, bRequest 0x80-0x9D) via a 30-entry jump table at CODE:0076. Range check: `(bRequest + 0x80) < 0x1E`, dispatching to `JMP @A+DPTR` at `0x76 + (bRequest - 0x80) * 2`.
+
+### Vendor Command Jump Table (0x80-0x9D)
+
+| bRequest | Name | v2.06 Target | v2.13 Target | Status |
+|----------|------|-------------|-------------|--------|
+| 0x80 | GET_8PSK_CONFIG | 0x00B2 | 0x00B2 | **Both**: Read config byte to EP0BUF (v2.06: IRAM 0x6D, v2.13: IRAM 0x4F) |
+| 0x81 | SET_8PSK_CONFIG | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** - not implemented in either |
+| 0x82 | (reserved) | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** |
+| 0x83 | I2C_WRITE | 0x00F1 | 0x00F1 | **Both**: Same I2C write handler |
+| 0x84 | I2C_READ | 0x0102 | 0x0102 | **Both**: Same I2C read handler |
+| 0x85 | ARM_TRANSFER | 0x0110 | 0x0110 | **Both**: Same ARM transfer handler |
+| 0x86 | TUNE_8PSK | 0x012E | 0x012E | **Both**: Same tuning handler |
+| 0x87 | GET_SIGNAL_STRENGTH | 0x0140 | 0x0162 | **CHANGED** - see section below |
+| 0x88 | LOAD_BCM4500 | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** - BCM4500 loading via different mechanism |
+| 0x89 | BOOT_8PSK | 0x00C4 | 0x00C4 | **Both**: Same boot handler |
+| 0x8A | START_INTERSIL | 0x019C | 0x01BE | **Relocated** but functionally similar |
+| 0x8B | SET_LNB_VOLTAGE | 0x01CB | 0x01ED | **Relocated** but functionally similar |
+| 0x8C | SET_22KHZ_TONE | 0x01DD | 0x01FF | **Relocated** but functionally similar |
+| 0x8D | SEND_DISEQC_COMMAND | 0x01EF | 0x0211 | **CHANGED** - different DiSEqC implementation |
+| 0x8E | SET_DVB_MODE | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** |
+| 0x8F | (unknown) | 0x01FC | 0x021E | Both: Similar read-back function |
+| 0x90 | GET_SIGNAL_LOCK | 0x020B | 0x022D | **Relocated** but functionally similar |
+| 0x91 | (unknown) | 0x022C | 0x024E | Both: I2C read-back |
+| 0x92 | (unknown) | 0x024A | 0x026C | Both: I2C read-back |
+| 0x93 | GET_SERIAL_NUMBER | 0x026F | 0x0293 | **Relocated** but functionally similar |
+| 0x94 | (unknown) | 0x01B9 | 0x01DB | Both: LNB-related |
+| 0x95 | (unknown) | 0x02DF | 0x0303 | Both: Read-back function |
+| 0x96 | (unknown) | 0x02B4 | 0x02D8 | Both: Similar handler |
+| 0x97 | (unknown) | 0x02C1 | 0x02E5 | Both: Similar handler |
+| 0x98 | (unknown) | 0x02CB | 0x02EF | Both: Similar handler |
+| 0x99 | **NEW: GET_DEMOD_STATUS** | 0x0326 (STALL) | 0x0317 | **ADDED in v2.13** |
+| 0x9A | **NEW: INIT_DEMOD** | 0x0326 (STALL) | 0x0140 | **ADDED in v2.13** |
+| 0x9B | (reserved) | 0x0326 (STALL) | 0x034A (STALL) | **Both STALL** |
+| 0x9C | **NEW: DELAY_COMMAND** | 0x0326 (STALL) | 0x032B | **ADDED in v2.13** |
+| 0x9D | SET_MODE_FLAG | 0x02FA | 0x033A | **CHANGED** - different implementation |
+
+### Commands Added in v2.13
+
+**0x99 - GET_DEMOD_STATUS (new read command)**
+```
+LCALL FUN_CODE_2421 ; calls FUN_CODE_2239(0x3F, 0xF9)
+ ; -> I2C read from device 0x3F, register 0xF9
+MOV EP0BUF[0], R7 ; return I2C read result
+EP0BCL = 1 ; send 1 byte back
+```
+Reads demodulator register 0xF9 via I2C (device address 0x3F) and returns the value to the host. This is a status/diagnostics register read for the satellite demodulator IC.
+
+**0x9A - INIT_DEMOD (new control command)**
+```
+LCALL 0x231E ; EP0 flush/prepare
+if (config_flags.0 == 1) { ; check if demodulator is present
+ counter = 0;
+ while (counter < 3) {
+ LCALL FUN_CODE_1977 ; initialization step
+ if (success) break;
+ counter++;
+ }
+}
+EP0BCL = 0 ; no data returned
+```
+Performs up to 3 attempts to initialize the demodulator, but only if the demodulator-present flag (bit 0 of DAT_INTMEM_4F) is set. This provides host-triggered re-initialization capability.
+
+**0x9C - DELAY_COMMAND (new control command)**
+```
+R7 = wValue ; delay parameter from USB SETUP packet
+LCALL FUN_CODE_1ac6 ; tuning/acquisition delay function
+EP0BCL = 0 ; no data returned
+```
+Calls FUN_CODE_1ac6 with the wValue parameter from the USB SETUP packet. FUN_CODE_1ac6 performs an I2C-based tuning acquisition sequence: it reads demod register 0xF9, writes control values to registers 0xF8 and 0xF9, then polls register 0xF9 up to 40 times (0x28) waiting for bit 0 to be set (lock acquired). If lock fails, it calls FUN_CODE_1e3c which performs a full demodulator reset sequence.
+
+### Commands Removed from v2.13
+None were removed -- all commands that were STALL in v2.06 remain STALL in v2.13.
+
+### Changed Command Implementations
+
+**0x87 - GET_SIGNAL_STRENGTH (modified)**
+- v2.06 at 0x0140: Checks DAT_INTMEM_6D bit 0 (demod active), reads three I2C status registers (0xA2, 0xA8, 0xA4) to compute signal quality, loops up to 6 iterations polling for demod readiness
+- v2.13 at 0x0162: Checks DAT_INTMEM_4F bit 0 (demod active), reads I2C but uses different function call chain (FUN_CODE_1278 vs FUN_CODE_0c97). Same overall logic with relocated internal variables.
+
+**0x8D - SEND_DISEQC_COMMAND (GPIO pin reassignment)**
+- v2.06: `LCALL 0x23e0; LCALL 0x1e41` -- GPIO bit-bang DiSEqC via FUN_CODE_2098, data on **P0.7**, carrier on P0.3
+- v2.13: `LCALL 0x231e; LCALL FUN_CODE_0dbc` -- GPIO bit-bang DiSEqC via FUN_CODE_2060, data on **P0.0**, carrier on P0.3
+
+Both versions use the identical algorithm:
+ 1. Read wLength (0xE6BE) as message byte count
+ 2. Clear P0.3 (disable 22kHz carrier)
+ 3. Delay 15 ticks via delay function (7.5ms settling time)
+ 4. If message bytes present: iterate through EP0BUF, sending each byte via Manchester-encoded bit-bang (8 data bits + odd parity, 3 Timer2 ticks per bit)
+ 5. If wValue == 0 and no bytes: tone burst A (25 Timer2 ticks = 12.5ms)
+ 6. If wValue != 0 and no bytes: tone burst B via byte transmit with 0xFF pattern
+
+**CORRECTION**: Earlier analysis incorrectly identified v2.13 as using "I2C-based DiSEqC." Deep decompilation of the sub-functions (FUN_CODE_2060, FUN_CODE_22f3, FUN_CODE_22b0) reveals they are GPIO bit-bang implementations identical in algorithm to v2.06's FUN_CODE_2098 and FUN_CODE_2372. The only change is the data pin assignment (P0.7 -> P0.0), reflecting a different PCB layout.
+
+**0x9D - SET_MODE_FLAG (different logic)**
+- v2.06: Reads byte at descriptor_base + 10, checks if value is 4, 5, or 6, and conditionally sets bit flag 0x06 based on wValue - 1
+- v2.13: Simply checks if wValue != 0, and if so calls FUN_CODE_21d1 which performs a conditional demodulator reset (calls FUN_CODE_1e3c if `_1_4` flag isn't already set, then writes I2C control registers 0xFC on both device 0x7F and 0x3F)
+
+---
+
+## 2. Key Function Correspondence
+
+| v2.06 Function | v2.13 Function | Role |
+|---------------|---------------|------|
+| `main` (0x188D) | `main_entry` (0x170D) | RESET vector - clears IRAM, processes init table, jumps to init |
+| `FUN_CODE_09a7` (0x09A7) | `FUN_CODE_0800` (0x0800) | Main init + main loop |
+| `FUN_CODE_13c3` (0x13C3) | `FUN_CODE_11ab` (0x11AB) | USB/peripheral descriptor setup |
+| `FUN_CODE_032a` (0x032A) | `FUN_CODE_034e` (0x034E) | Standard USB request handler |
+| `FUN_CODE_0056` (0x0056) | `FUN_CODE_0056` (0x0056) | Vendor request dispatcher (identical code) |
+| `FUN_CODE_2297` (0x2297) | `FUN_CODE_21ec` (0x21EC) | Main loop poll (USB IRQ processing) |
+| `FUN_CODE_21ed` (0x21ED) | `FUN_CODE_2189` (0x2189) | EP2CS setup + PCON idle |
+| `FUN_CODE_211d` (0x211D) | `FUN_CODE_20b9` (0x20B9) | CPUCS reset pulse (EP2 management) |
+| `FUN_CODE_2174` (0x2174) | `FUN_CODE_2110` (0x2110) | USB descriptor type walker (identical code) |
+| `FUN_CODE_1919` (0x1919) | `FUN_CODE_1800` (0x1800) | GPIF/FIFO management (identical logic) |
+| `FUN_CODE_1d4f` (0x1D4F) | -- | v2.06 demod init (GPIO-based, complex) |
+| -- | `FUN_CODE_1d4b` (0x1D4B) | v2.13 demod init (I2C write 4 bytes to 0x7F/0xF0) |
+| `FUN_CODE_1da8` (0x1DA8) | -- | v2.06 I2C read with timeout (uses FUN_CODE_1556) |
+| -- | `FUN_CODE_0eea` (0x0EEA) | v2.13 I2C read with retry (20 attempts) |
+| `FUN_CODE_1dfb` (0x1DFB) | `FUN_CODE_14b9` (0x14B9) | Delay loop (clock-dependent timing) |
+| `FUN_CODE_1cf3` (0x1CF3) | `FUN_CODE_1c44` (0x1C44) | Configuration update function |
+| `FUN_CODE_12ea` (0x12EA) | `FUN_CODE_1000` (0x1000) | USB endpoint configuration |
+| `FUN_CODE_0ddd` (0x0DDD) | `FUN_CODE_0ca4` (0x0CA4) | BCM4500 firmware loader |
+| `FUN_CODE_2000` (0x2000) | `FUN_CODE_208d` (0x208D) | BCM4500 status polling |
+| `FUN_CODE_1556` (0x1556) | `FUN_CODE_0eea` (0x0EEA) | I2C multi-byte transfer |
+| `FUN_CODE_24d2` (0x24D2) | `FUN_CODE_243d` (0x243D) | SET_DVB_MODE config store |
+| `FUN_CODE_2419` (0x2419) | `FUN_CODE_2357` (0x2357) | GET config byte to EP0BUF |
+| `FUN_CODE_23cb` (0x23CB) | `FUN_CODE_2309` (0x2309) | Read descriptor byte to EP0BUF |
+| `FUN_CODE_1a0e` (0x1A0E) | -- | v2.06 serial number reader (EEPROM) |
+| `INT0_vec` (0x0003) | `INT0_vector` (0x0003) | INT0 interrupt handler (**significantly different**) |
+| -- | `FUN_CODE_2239` (0x2239) | v2.13 I2C single-byte read helper |
+| -- | `FUN_CODE_2031` (0x2031) | v2.13 USB reconnect function |
+| -- | `FUN_CODE_1799` (0x1799) | v2.13 demod checksum/signature verify |
+| -- | `FUN_CODE_1ca0` (0x1CA0) | v2.13 descriptor checksum verify |
+| -- | `FUN_CODE_1ac6` (0x1AC6) | v2.13 tuning acquisition sequence |
+| -- | `FUN_CODE_1e3c` (0x1E3C) | v2.13 demodulator full reset |
+| -- | `FUN_CODE_10d9` (0x10D9) | v2.13 demod status polling/init |
+| -- | `FUN_CODE_0dbc` (0x0DBC) | v2.13 DiSEqC GPIO bit-bang wrapper (data on P0.0) |
+
+### USB Descriptor Setup (FUN_CODE_13c3 vs FUN_CODE_11ab)
+
+Both functions are structurally identical:
+1. Disable USB disconnect (0xE605 bit 1 clear)
+2. Configure IFCONFIG (0xE600) for internal clock, 48MHz
+3. Set REVCTL (0xE601) to 0xCA
+4. Configure GPIFIDLECTL, PORTACFG
+5. Set PORT registers (P0, P3, IPL1)
+6. Configure GPIFCTLCFG, FIFORESET, FIFOPINPOLAR
+7. Configure Timer2 (RCAP2H=0xF8, RCAP2L=0x2F -> ~2ms period at 48MHz/12)
+8. Initialize subsystem modules
+
+Key difference: v2.13 calls `INT0_vector()` (the INT0 handler) during initialization as a probing step. This runs the demodulator availability check during USB setup, before enabling interrupts. v2.06 does not do this.
+
+Descriptor pointer offsets:
+- v2.06: BANK1_R4:R5 = 0x1200 (descriptor base)
+- v2.13: BANK1_R4:R5 = 0x0E00 (descriptor base, lower due to code restructuring)
+
+---
+
+## 3. Structural Differences
+
+### 3.1 v2.13 Retry Loops (FUN_CODE_1799 and FUN_CODE_1ca0)
+
+In the main init function `FUN_CODE_0800`, v2.13 has:
+
+```c
+// Retry loop 1: FUN_CODE_1799 - demodulator signature verification
+DAT_INTMEM_36 = 0x14; // 20 attempts
+while (DAT_INTMEM_36 != 0 && FUN_CODE_1799() fails) {
+ DAT_INTMEM_36--;
+}
+if (DAT_INTMEM_36 == 0) {
+ FUN_CODE_1ac6(100); // tuning acquisition with 100ms delay
+}
+
+// Retry loop 2: FUN_CODE_1ca0 - descriptor checksum verification
+DAT_INTMEM_36 = 0x14; // 20 attempts
+while (DAT_INTMEM_36 != 0 && FUN_CODE_1ca0() fails) {
+ DAT_INTMEM_36--;
+}
+if (DAT_INTMEM_36 == 0) {
+ FUN_CODE_1ac6(100); // tuning acquisition with 100ms delay
+}
+```
+
+**FUN_CODE_1799 - Demodulator Signature Verification:**
+1. Calls FUN_CODE_1d4b() which writes 4 bytes via I2C to device 0x7F, register 0xF0 (demodulator control)
+2. Saves parameters DAT_INTMEM_39:3A
+3. Checks if parameters match 0x021C (known good value) - returns early if match
+4. Reads 5 I2C bytes via FUN_CODE_0718, each at register 0x0A offset (stepping by 2)
+5. Subtracts 0x30 ('0') from each byte (ASCII to binary conversion)
+6. Sums the values and compares sum to the saved parameters
+7. Returns success (carry set) if checksum matches
+
+This verifies the demodulator responds correctly with the expected identification pattern. The ASCII-to-binary conversion suggests the demod returns a readable version string at register 0x0A.
+
+**FUN_CODE_1ca0 - Descriptor Checksum Verification:**
+1. Iterates bytes 6 through 0x29 (36 bytes) of the BANK2_R6:R7 descriptor block
+2. Computes running sum, compares against expected value 0x0706
+3. If first block passes, iterates bytes 0x2C through 0x4F (36 bytes) of same block
+4. Computes second running sum, compares against expected value 0x0686
+5. Returns success only if both checksums match
+
+This validates the integrity of a 2-block descriptor/configuration structure (possibly EEPROM-loaded calibration data).
+
+**v2.06 equivalent:** v2.06 does NOT have these retry loops. It calls `FUN_CODE_1a0e` (serial number/EEPROM reader) directly without verification, then proceeds immediately. There is no signature check or checksum validation.
+
+### 3.2 Version Byte Check (Hardware Revision Detection)
+
+After the retry loops, v2.13 performs:
+
+```c
+// Read byte at descriptor_base + 10
+byte version_byte = *(BANK1_R4:R5 + 10); // 0x0E0A
+if (version_byte == 0x03) {
+ bVar4 = 0x80; // flag = set
+} else {
+ bVar4 = 0; // flag = clear
+}
+_1_3 = bVar4 >> 7; // store as bit flag _1_3
+```
+
+This reads byte offset 10 from the USB descriptor base address. Offset 10 in a USB device descriptor is `bMaxPacketSize0` in standard USB, but since this is a custom descriptor area, it likely encodes a hardware revision. The value 0x03 sets bit flag `_1_3`, creating a hardware-revision-aware code path.
+
+**Impact:** The `_1_3` flag is used elsewhere in v2.13 to conditionally execute different initialization sequences, supporting multiple hardware revisions of the SkyWalker-1 board.
+
+### 3.3 FUN_CODE_2031 - USB Reconnect Before Main Loop
+
+```c
+void FUN_CODE_2031(void) {
+ if (_0_0 == 0) {
+ CPUCS |= 0x08; // Set CPUCS.3 (8051 reset bit? Or re-enumerate)
+ } else {
+ CPUCS |= 0x0A; // Set CPUCS.3 + CPUCS.1
+ }
+ FUN_CODE_14b9(5, 0xDC); // Delay ~1500 cycles
+ EPIRQ = 0xFF; // Clear all endpoint interrupts
+ USBIRQ = 0xFF; // Clear all USB interrupts
+ DAT_SFR_91 &= 0xEF; // Clear EXIF.4 (USB interrupt flag)
+ CPUCS &= 0xF7; // Clear CPUCS.3
+}
+```
+
+This performs a controlled USB re-enumeration by pulsing CPUCS.3, then clearing all pending USB/endpoint interrupts. The conditional on `_0_0` adds CPUCS.1 when the flag is set (possibly switching between 12MHz and 48MHz operation).
+
+**v2.06 equivalent:** In v2.06, this exact same logic exists as `INT0_vec` (the INT0 interrupt handler at 0x0003). The critical difference is that in v2.06 this code runs as an interrupt handler, while in v2.13 it's called as a normal function (`FUN_CODE_2031`) before the main loop starts, AND the INT0 vector is repurposed for demodulator polling (see section 4).
+
+---
+
+## 4. INT0 Handler Difference
+
+### v2.06 INT0 (CODE:0003) - USB Re-enumeration
+
+```c
+void INT0_vec(void) {
+ if (_0_7 == 0) {
+ CPUCS |= 0x08; // CPUCS bit 3
+ } else {
+ CPUCS |= 0x0A; // CPUCS bits 3+1
+ }
+ FUN_CODE_1dfb(5, 0xDC); // Delay
+ EPIRQ = 0xFF; // Clear endpoint IRQs
+ USBIRQ = 0xFF; // Clear USB IRQs
+ DAT_SFR_91 &= 0xEF; // Clear external interrupt flag
+ CPUCS &= 0xF7; // Clear CPUCS bit 3
+}
+```
+
+Simple USB reconnect/re-enumeration handler. Pulses CPUCS.3, clears all pending interrupts.
+
+### v2.13 INT0 (CODE:0003) - Demodulator Availability Polling
+
+```c
+void INT0_vector(void) {
+ for (DAT_INTMEM_37 = 0x28; DAT_INTMEM_37 != 0; DAT_INTMEM_37--) {
+ // Read I2C device 0x7F (demod A), checking for response
+ byte result = FUN_CODE_2239(0x7F); // I2C read from 0x7F
+ if (result != 0x01) {
+ // Try I2C device 0x3F (demod B)
+ result = FUN_CODE_2239(0x3F); // I2C read from 0x3F
+ if (result != 0x01) break; // Neither responded normally
+ }
+ }
+ _1_4 = (DAT_INTMEM_37 == 0); // Set flag if loop exhausted (no demod found)
+}
+```
+
+This is a complete replacement of INT0's purpose. Instead of USB re-enumeration, INT0 now polls two I2C devices (0x7F and 0x3F) up to 40 times (0x28). These are two possible addresses for the satellite demodulator IC.
+
+**FUN_CODE_2239 decompiled:**
+```c
+undefined1 FUN_CODE_2239(byte device_addr) {
+ DAT_INTMEM_48 = 0xE1; // buffer address high
+ DAT_INTMEM_49 = 0; // buffer address low
+ FUN_CODE_0eea(1, device_addr, 0x51); // I2C read 1 byte from device
+ return DAT_EXTMEM_e100; // return the read byte
+}
+```
+
+The function performs an I2C single-byte read from the specified device address, using address 0x51 as a parameter (likely selecting a specific I2C bus or mode via the FX2's auxiliary I2C controller at 0xE678). It stores the result at 0xE100 (XRAM buffer).
+
+**Behavioral meaning:** The flag `_1_4` is set to 1 if neither demodulator responded after 40 attempts - indicating no demodulator hardware is present. This flag is later checked by:
+- `FUN_CODE_21d1` (command 0x9D handler) - skips demodulator reset if `_1_4 != 1`
+- Various initialization paths to avoid hanging on missing hardware
+
+**Why this matters:** v2.06 assumes the demodulator is always present. v2.13 can detect and gracefully handle boards where the demodulator is absent or unresponsive, making it more robust for manufacturing QC and field failures.
+
+---
+
+## 5. What Can v2.13 Do That v2.06 Cannot?
+
+### 5.1 Demodulator Hardware Detection
+v2.13 probes two I2C addresses (0x7F, 0x3F) at startup to determine which demodulator variant is installed, or if none is present. v2.06 blindly assumes the hardware configuration.
+
+### 5.2 Host-Initiated Demodulator Re-initialization (Command 0x9A)
+The host can trigger a demodulator re-initialization via USB vendor command 0x9A, with up to 3 retry attempts. v2.06 has no mechanism for the host to request re-initialization.
+
+### 5.3 Demodulator Status Read (Command 0x99)
+Direct I2C register read of demodulator register 0xF9, returned to host. This enables diagnostic/monitoring software to check demodulator status without going through the full signal quality pipeline.
+
+### 5.4 Host-Controlled Tuning Delay (Command 0x9C)
+Allows the host to invoke the tuning acquisition sequence with a configurable delay parameter. In v2.06, the tuning timing is entirely firmware-controlled with no host influence.
+
+### 5.5 DiSEqC GPIO Pin Reassignment
+All firmware versions use the same GPIO bit-bang algorithm for DiSEqC signaling. The only change is the data pin assignment per PCB revision:
+
+| Version | Data Pin | Carrier Pin | Byte Transmit | Bit Symbol | Timer Tick |
+|---------|----------|-------------|--------------|------------|------------|
+| v2.06 | **P0.7** | P0.3 | 0x2098 | 0x23B5 | 0x24C6 |
+| Rev.2 v2.10 | **P0.4** | P0.3 | FUN_CODE_07d1 | FUN_CODE_213c | FUN_CODE_225f |
+| v2.13 FW1 | **P0.0** | P0.3 | FUN_CODE_2060 | FUN_CODE_22f3 | func_0x2431 |
+
+The algorithm is identical across all versions: Manchester-encoded bit-bang with Timer2-based timing, odd parity per byte, and 25-tick tone bursts for mini-commands.
+
+### 5.6 Firmware/Descriptor Integrity Verification
+v2.13 validates demodulator identification (ASCII version string checksum) and descriptor block integrity (two 36-byte checksums) before proceeding. If verification fails after 20 attempts, it falls back to a recovery sequence. v2.06 does no integrity checking.
+
+### 5.7 Hardware Revision Awareness
+The version byte check (descriptor offset 10, value 0x03) creates conditional code paths allowing a single firmware image to support multiple SkyWalker-1 hardware revisions. v2.06 has a single code path for one hardware revision.
+
+### 5.8 Simplified BCM4500 Status Polling
+v2.06's `FUN_CODE_2000` polls three separate BCM4500 registers (0xA2, 0xA8, 0xA4 via I2C) to determine demodulator readiness. v2.13's `FUN_CODE_208d` polls only one register (0xA4), suggesting either the demodulator firmware was updated to consolidate status, or the additional checks were found to be redundant.
+
+### 5.9 Conditional Demodulator Reset (Command 0x9D)
+v2.13's 0x9D handler can trigger a full demodulator reset sequence (FUN_CODE_1e3c -> register writes to 0x18 bus) controlled by the host via wValue. This is useful for error recovery without full device re-enumeration.
+
+---
+
+## 6. Architecture Summary
+
+| Aspect | v2.06 | v2.13 |
+|--------|-------|-------|
+| Total functions | 61 | 82 (+21) |
+| RESET vector | 0x188D | 0x170D |
+| Stack pointer | 0x72 | 0x50 |
+| Init data table | CODE:0B46 | CODE:0B88 |
+| Descriptor base | 0x1200 | 0x0E00 |
+| Config byte (IRAM) | 0x6D | 0x4F |
+| INT0 purpose | USB re-enumerate | Demod probe |
+| DiSEqC data pin | P0.7 (GPIO bit-bang) | P0.0 (GPIO bit-bang) |
+| Demod init | Direct, no retry | 20-attempt retry |
+| Integrity checks | None | Checksum verification |
+| HW revision support | Single | Multi-revision (flag _1_3) |
+| New vendor cmds | -- | 0x99, 0x9A, 0x9C |
+
+---
+
+## 7. DiSEqC Timing Chain Analysis
+
+### 7.1 Timer2 Configuration (Identical Across All Versions)
+
+All firmware versions configure Timer2 identically during USB descriptor setup:
+
+```
+T2CON = 0x04 ; Auto-reload mode, internal clock, TR2=1 (running)
+RCAP2H = 0xF8 ; Reload high byte
+RCAP2L = 0x2F ; Reload low byte -> RCAP2 = 0xF82F = 63535
+CKCON = 0x00 ; Default (T2M=0 -> Timer2 clock = CLKOUT/12)
+```
+
+**Timer2 Clock Derivation:**
+```
+FX2 master clock = 48 MHz
+CKCON.T2M = 0 -> Timer2 clock = 48 MHz / 12 = 4 MHz
+Count per overflow = 65536 - 63535 = 2001
+Tick period = 2001 / 4,000,000 = 500.25 us ~ 500 us
+Tick frequency ~ 2.0 kHz
+```
+
+Timer2 runs continuously from power-on and is never stopped or reconfigured. It serves as a stable 500 us timebase for all DiSEqC operations.
+
+### 7.2 DiSEqC Signal Architecture
+
+```
+FX2 Firmware External Hardware Coax Cable
++------------------+ +--------------------+ +------------------+
+| | | | | |
+| P0.3 (carrier) |---->| 22 kHz oscillator |---->| LNB power line |
+| (enable/disable) | | (gated by P0.3) | | (13V/18V + tone) |
+| | | | | |
+| P0.x (data bit) | | (internal to FX2 | | |
+| (firmware only) | | firmware logic) | | |
++------------------+ +--------------------+ +------------------+
+```
+
+The firmware does NOT generate the 22 kHz carrier directly. P0.3 gates an external
+22 kHz oscillator circuit on the PCB. The data pin (P0.7/P0.4/P0.0 depending on
+version) is used only internally by the firmware to control the Manchester encoding
+logic -- it tells the bit-symbol function whether to cut the carrier short or leave
+it on for the full period.
+
+### 7.3 Manchester Encoding (DiSEqC Bit Symbol)
+
+Each DiSEqC bit consists of 3 Timer2 ticks (3 x 500 us = 1.5 ms):
+
+**Data '0' (2/3 tone, 1/3 silence):**
+```
+ Tick 1 Tick 2 Tick 3
+ (500 us) (500 us) (500 us)
+P0.3: _____|========|========|________|
+ ^tone ON ^tone OFF
+ (setup gap) (1.0 ms carrier) (0.5 ms silence)
+```
+
+**Data '1' (1/3 tone, 2/3 silence):**
+```
+ Tick 1 Tick 2 Tick 3
+ (500 us) (500 us) (500 us)
+P0.3: _____|========|________|________|
+ ^tone ON ^tone OFF early
+ (setup gap) (0.5 ms carrier) (1.0 ms silence)
+```
+
+**Implementation (decompiled from Rev.2 FUN_CODE_213c):**
+```c
+void diseqc_bit_symbol(void) {
+ wait_TF2(); // Tick 1: inter-bit gap (500 us)
+ P0 |= 0x08; // P0.3 = 1 -> 22 kHz carrier ON
+ wait_TF2(); // Tick 2: carrier period (500 us)
+ if (data_pin != 0) { // If data = '1':
+ P0 &= 0xF7; // P0.3 = 0 -> carrier OFF (short pulse)
+ }
+ wait_TF2(); // Tick 3: final period (500 us)
+ P0 &= 0xF7; // P0.3 = 0 -> carrier always OFF at end
+}
+```
+
+### 7.4 Byte Transmission (8 Data Bits + Odd Parity)
+
+Each DiSEqC byte is 9 bits: 8 data (MSB first) + 1 parity (odd).
+
+**Implementation (decompiled from Rev.2 FUN_CODE_07d1):**
+```c
+void diseqc_send_byte(char first_byte, byte data) {
+ byte ones_count = 0;
+ if (first_byte == 0) TF2 = 0; // Sync timer on first byte
+
+ for (char i = 8; i > 0; i--) { // 8 bits, MSB first
+ if (data & 0x80) { // Test MSB
+ data_pin = 1; // Set data = '1'
+ diseqc_bit_symbol(); // Transmit '1' symbol
+ ones_count++;
+ } else {
+ data_pin = 0; // Set data = '0'
+ diseqc_bit_symbol(); // Transmit '0' symbol
+ }
+ data <<= 1; // Next bit
+ }
+
+ data_pin = ~ones_count & 1; // Odd parity: '1' if even count
+ diseqc_bit_symbol(); // Transmit parity bit
+}
+```
+
+**Timing per byte:** 9 bits x 1.5 ms = 13.5 ms
+
+### 7.5 Tone Burst (Mini DiSEqC Command)
+
+For legacy 2-way satellite switches, a simple tone burst is used instead of a
+full DiSEqC message. The burst is 25 Timer2 ticks of continuous carrier:
+
+```c
+void tone_burst_A(void) {
+ TF2 = 0; // Sync timer
+ wait_TF2(); // One tick gap
+ P0 |= 0x08; // P0.3 = 1 -> carrier ON
+ for (char i = 25; i > 0; i--) {
+ wait_TF2(); // 25 x 500 us = 12.5 ms
+ }
+ P0 &= 0xF7; // P0.3 = 0 -> carrier OFF
+}
+```
+
+**Burst duration:** 25 x 500 us = 12.5 ms (matches DiSEqC spec)
+
+### 7.6 Timer Tick Wait (TF2 Polling)
+
+The lowest-level timing primitive is a busy-wait on Timer2 overflow:
+
+```c
+void wait_TF2(void) {
+ while (TF2 == 0) {} // Poll Timer2 overflow flag
+ TF2 = 0; // Clear flag for next tick
+}
+```
+
+This is identical across all versions (v2.06: 0x24C6, Rev.2: FUN_CODE_225f,
+v2.13: func_0x2431). Timer2 overflows every 500.25 us, providing the fundamental
+DiSEqC timebase.
+
+### 7.7 CPU Clock Compensation (Delay Function)
+
+The delay function used before DiSEqC transmission adjusts for CPU clock speed:
+
+```c
+void delay(byte high, byte low) {
+ byte clkspd = CPUCS & 0x18; // CPUCS[4:3] = clock speed bits
+ if (clkspd == 0x00) { // 12 MHz: halve the count
+ // Adjust high:low /= 2
+ } else if (clkspd == 0x10) { // 48 MHz: double the count
+ // Adjust high:low *= 2
+ }
+ // 24 MHz (0x08): use count as-is
+ while (high:low > 0) {
+ wait_TF2();
+ high:low--;
+ }
+}
+```
+
+The pre-DiSEqC delay call is `delay(0, 0x0F)` = 15 ticks x 500 us = 7.5 ms.
+This allows the LNB voltage to stabilize before DiSEqC signaling begins.
+
+### 7.8 Complete DiSEqC Timing Summary
+
+| Parameter | Value | Source |
+|-----------|-------|--------|
+| Timer2 clock | 4 MHz (48 MHz / 12) | CKCON default, T2M=0 |
+| Timer2 reload | 0xF82F | RCAP2H:RCAP2L |
+| Tick period | 500.25 us | (65536 - 63535) / 4 MHz |
+| Bit period | 1.5 ms (3 ticks) | DiSEqC Manchester encoding |
+| Byte period | 13.5 ms (9 bits) | 8 data + 1 parity |
+| Tone burst | 12.5 ms (25 ticks) | Mini-command A/B |
+| Pre-TX delay | 7.5 ms (15 ticks) | Voltage settling |
+| Data '0' | 1.0 ms tone + 0.5 ms silence | 2/3 duty cycle |
+| Data '1' | 0.5 ms tone + 1.0 ms silence | 1/3 duty cycle |
+| Carrier frequency | 22 kHz (external oscillator) | Gated by P0.3 |
+| Carrier enable | P0.3 | All versions |
+| Data pin (v2.06) | P0.7 | PCB revision A |
+| Data pin (Rev.2) | P0.4 | PCB revision B |
+| Data pin (v2.13) | P0.0 | PCB revision C |
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1AntennaPin.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1AntennaPin.h
index fa36639..c0ca6bd 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1AntennaPin.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1AntennaPin.h
@@ -1,102 +1,102 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1AntennaPin.h
- Author :
- Date :
- Purpose : This File Holds the Antenna Pin related declarations
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_ANTENNA_PIN_H
-#define __SKYWALKER1_ANTENNA_PIN_H
-
-/* Include the Library and Other header file */
-#include "SkyWalker1TunerPin.h"
-#include "SkyWalker1Extended.h" //For the Extended BDA
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-//Antenna Pin class.
-class CAntennaPin : public CTunerPin
-{
-public:
-
- static NTSTATUS PinSetDeviceState(
- IN PKSPIN Pin,
- IN KSSTATE ToState,
- IN KSSTATE FromState
- );
-
- static NTSTATUS IntersectDataFormat(
- IN PVOID pContext,
- IN PIRP pIoRequestPacket,
- IN PKSP_PIN Pin,
- IN PKSDATARANGE DataRange,
- IN PKSDATARANGE MatchingDataRange,
- IN ULONG DataBufferSize,
- OUT PVOID Data OPTIONAL,
- OUT PULONG DataSize
- );
-
- //Network provider and AVStream use these functions
- //to set and get properties of nodes that are controlled
- //by the input pin.
-
- static NTSTATUS GetTunerProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
- static NTSTATUS SetTunerProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
-
-
- //Network provider and AVStream use these functions
- //to set and get properties of nodes that are controlled
- //by the input pin.
- static NTSTATUS GetTunerLnbProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
- static NTSTATUS SetTunerLnbProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
-private:
-
- KSSTATE m_KsState;
-};
-
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1AntennaPin.h
+ Author :
+ Date :
+ Purpose : This File Holds the Antenna Pin related declarations
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_ANTENNA_PIN_H
+#define __SKYWALKER1_ANTENNA_PIN_H
+
+/* Include the Library and Other header file */
+#include "SkyWalker1TunerPin.h"
+#include "SkyWalker1Extended.h" //For the Extended BDA
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+//Antenna Pin class.
+class CAntennaPin : public CTunerPin
+{
+public:
+
+ static NTSTATUS PinSetDeviceState(
+ IN PKSPIN Pin,
+ IN KSSTATE ToState,
+ IN KSSTATE FromState
+ );
+
+ static NTSTATUS IntersectDataFormat(
+ IN PVOID pContext,
+ IN PIRP pIoRequestPacket,
+ IN PKSP_PIN Pin,
+ IN PKSDATARANGE DataRange,
+ IN PKSDATARANGE MatchingDataRange,
+ IN ULONG DataBufferSize,
+ OUT PVOID Data OPTIONAL,
+ OUT PULONG DataSize
+ );
+
+ //Network provider and AVStream use these functions
+ //to set and get properties of nodes that are controlled
+ //by the input pin.
+
+ static NTSTATUS GetTunerProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+ static NTSTATUS SetTunerProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+
+
+ //Network provider and AVStream use these functions
+ //to set and get properties of nodes that are controlled
+ //by the input pin.
+ static NTSTATUS GetTunerLnbProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+ static NTSTATUS SetTunerLnbProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+private:
+
+ KSSTATE m_KsState;
+};
+
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_TRANSPORT_PIN_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CaptureFilter.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CaptureFilter.h
index bbe9723..b078715 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CaptureFilter.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CaptureFilter.h
@@ -1,72 +1,72 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1CaptureFilter.h
- Author :
- Date :
- Purpose : This file contains the filter level header for
- the capture filter.
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef SKYWALKER1_CAPTURE_FILTER_H
-#define SKYWALKER1_CAPTURE_FILTER_H
-
-/* Include the Library and Other header file */
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-//The Capture filter class.
-class CCaptureFilter
-{
-public:
-
- //The capture filter object constructor. Since the new operator will
- //have zeroed the memory, do not bother initializing any NULL or 0
- //fields. Only initialize non-NULL, non-0 fields.
- CCaptureFilter (IN PKSFILTER Filter);
-
- //The capture filter destructor.
- ~CCaptureFilter ();
-
- //This is the filter creation dispatch for the capture filter. It
- //creates the CCaptureFilter object, associates it with the AVStream
- //object, and bags it for easy cleanup later.
- static NTSTATUS Create( IN OUT PKSFILTER pKSFilter,
- IN PIRP pIoRequestPacket);
-
-
-private:
-
- //The AVStream filter object associated with this CCaptureFilter.
- PKSFILTER m_Filter;
-
- //This is the bag cleanup callback for the CCaptureFilter. Not providing
- //one would cause ExFreePool to be used. This is not good for C++
- //constructed objects. We simply delete the object here.
- static void Cleanup ( IN CCaptureFilter *CapFilter );
-
-};
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1CaptureFilter.h
+ Author :
+ Date :
+ Purpose : This file contains the filter level header for
+ the capture filter.
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef SKYWALKER1_CAPTURE_FILTER_H
+#define SKYWALKER1_CAPTURE_FILTER_H
+
+/* Include the Library and Other header file */
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+//The Capture filter class.
+class CCaptureFilter
+{
+public:
+
+ //The capture filter object constructor. Since the new operator will
+ //have zeroed the memory, do not bother initializing any NULL or 0
+ //fields. Only initialize non-NULL, non-0 fields.
+ CCaptureFilter (IN PKSFILTER Filter);
+
+ //The capture filter destructor.
+ ~CCaptureFilter ();
+
+ //This is the filter creation dispatch for the capture filter. It
+ //creates the CCaptureFilter object, associates it with the AVStream
+ //object, and bags it for easy cleanup later.
+ static NTSTATUS Create( IN OUT PKSFILTER pKSFilter,
+ IN PIRP pIoRequestPacket);
+
+
+private:
+
+ //The AVStream filter object associated with this CCaptureFilter.
+ PKSFILTER m_Filter;
+
+ //This is the bag cleanup callback for the CCaptureFilter. Not providing
+ //one would cause ExFreePool to be used. This is not good for C++
+ //constructed objects. We simply delete the object here.
+ static void Cleanup ( IN CCaptureFilter *CapFilter );
+
+};
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*SKYWALKER1_CAPTURE_FILTER_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CapturePin.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CapturePin.h
index 28d06f5..b2c5442 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CapturePin.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CapturePin.h
@@ -1,161 +1,161 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1CapturePin.h
- Author :
- Date :
- Purpose : This file contains header for the video capture pin on the capture
- filter.
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-/* Include the Library and Other header file */
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-//This Structure can be used in future for the
-//better stream management
-typedef struct _STREAM_POINTER_CONTEXT
-{
- ULONG ulFrameIndex;
-
-} STREAM_POINTER_CONTEXT, *PSTREAM_POINTER_CONTEXT;
-
-
-//The video capture pin class.
-class CCapturePin : public ICaptureSink
-{
-
-private:
-
- //The AVStream pin we're associated with.
- PKSPIN m_Pin;
-
- //Pointer to the internal device object for our capture device.
- //We access the Device through this object.
- CSkyWalker1Device *m_Device;
-
- //The state we've put the hardware into. This allows us to keep track
- //of whether to do things like unpausing or restarting.
- HARDWARE_STATE m_HardwareState;
-
- //The clock we've been assigned. As with other capture filters, we do
- //not expose a clock. If one has been assigned, we will use it to
- //time stamp packets (plus a reasonable delta to work the capture stream
- //in a preview graph).
- PIKSREFERENCECLOCK m_Clock;
-
- //The transport information for this capture pin. The settings for device will be
- //programmed for this transport info.
- PBDA_TRANSPORT_INFO m_TransportInfo;
-
- //This Variable is used to keep the count of the Streams sent for the
- //Data read
- ULONG m_CurrentFrameIndex;
-
- //An indication of whether or not this pin has acquired the necessary
- //hardware resources to operate. When the pin reaches KSSTATE_ACQUIRE,
- //we attempt to acquire the hardware. This flag will be set based on
- //our success / failure.
- BOOLEAN m_AcquiredResources;
-
- //Clean up any references we hold on frames in the queue. This is called
- //when we abruptly stop the fake hardware.
- NTSTATUS CleanupReferences ();
-
- //This is the state transition handler for the capture pin. It attempts
- //to acquire resources for the capture pin (or releasing them if
- //necessary) and starts and stops the hardware as required.
- NTSTATUS SetState ( IN KSSTATE ToState,IN KSSTATE FromState);
-
- //This is the processing dispatch for the capture pin. It handles
- //sending the Streams to the Device.
- NTSTATUS Process();
-
- //This routine is not required as the Transport Information is already
- //provided into the CCapturePin but still using it to make the
- //settings flexible
- PBDA_TRANSPORT_INFO CaptureBdaTransportInfo ();
-
- //This is the free callback from the bagged item (CCapturePin). If we
- //do not provide a callback when we bag the CCapturePin, ExFreePool
- //would be called. This is not desirable for C++ constructed objects.
- //We merely delete the object here.
- static void Cleanup (IN CCapturePin *Pin)
- {
- delete Pin;
- }
-
-public:
-
-
- //The capture pin's constructor. Initialize any non-0, non-NULL fields
- //(since new will have zero'ed the memory anyway) and set up our
- //device level pointers for access during capture routines.
- CCapturePin (IN PKSPIN Pin);
-
- //The capture pin's destructor.
- ~CCapturePin ();
-
- CSkyWalker1Device* GetDevice()
- {
- return m_Device;
- }
-
- //This is the capture sink notification mechanism for mapping completion.
- //When the device DPC detects that a given number of mappings have been
- //completed by the fake hardware, it signals the capture sink of this
- //through this method.
- virtual void ReleaseStream(IN ULONG ulStreamIndex);
-
- //This is the creation dispatch for the capture pin. It creates
- //the CCapturePin object and associates it with the AVStream object
- //bagging it in the process.
- static NTSTATUS PinCreate( IN OUT PKSPIN pKSPin,
- IN PIRP pIoRequestPacket
- );
-
- //This is the set device state dispatch for the pin. The routine bridges
- //to SetState() in the context of the CCapturePin.
- static NTSTATUS DispatchSetState (
- IN PKSPIN Pin,
- IN KSSTATE ToState,
- IN KSSTATE FromState
- )
- {
- return
- (reinterpret_cast(Pin->Context))->
- SetState(ToState, FromState);
- }
-
- //This is the processing dispatch for the capture pin. The routine
- //bridges to Process() in the context of the CCapturePin.
- static NTSTATUS DispatchProcess (IN PKSPIN Pin)
- {
- return
- (reinterpret_cast(Pin->Context))->Process();
- }
-};
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1CapturePin.h
+ Author :
+ Date :
+ Purpose : This file contains header for the video capture pin on the capture
+ filter.
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+/* Include the Library and Other header file */
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+//This Structure can be used in future for the
+//better stream management
+typedef struct _STREAM_POINTER_CONTEXT
+{
+ ULONG ulFrameIndex;
+
+} STREAM_POINTER_CONTEXT, *PSTREAM_POINTER_CONTEXT;
+
+
+//The video capture pin class.
+class CCapturePin : public ICaptureSink
+{
+
+private:
+
+ //The AVStream pin we're associated with.
+ PKSPIN m_Pin;
+
+ //Pointer to the internal device object for our capture device.
+ //We access the Device through this object.
+ CSkyWalker1Device *m_Device;
+
+ //The state we've put the hardware into. This allows us to keep track
+ //of whether to do things like unpausing or restarting.
+ HARDWARE_STATE m_HardwareState;
+
+ //The clock we've been assigned. As with other capture filters, we do
+ //not expose a clock. If one has been assigned, we will use it to
+ //time stamp packets (plus a reasonable delta to work the capture stream
+ //in a preview graph).
+ PIKSREFERENCECLOCK m_Clock;
+
+ //The transport information for this capture pin. The settings for device will be
+ //programmed for this transport info.
+ PBDA_TRANSPORT_INFO m_TransportInfo;
+
+ //This Variable is used to keep the count of the Streams sent for the
+ //Data read
+ ULONG m_CurrentFrameIndex;
+
+ //An indication of whether or not this pin has acquired the necessary
+ //hardware resources to operate. When the pin reaches KSSTATE_ACQUIRE,
+ //we attempt to acquire the hardware. This flag will be set based on
+ //our success / failure.
+ BOOLEAN m_AcquiredResources;
+
+ //Clean up any references we hold on frames in the queue. This is called
+ //when we abruptly stop the fake hardware.
+ NTSTATUS CleanupReferences ();
+
+ //This is the state transition handler for the capture pin. It attempts
+ //to acquire resources for the capture pin (or releasing them if
+ //necessary) and starts and stops the hardware as required.
+ NTSTATUS SetState ( IN KSSTATE ToState,IN KSSTATE FromState);
+
+ //This is the processing dispatch for the capture pin. It handles
+ //sending the Streams to the Device.
+ NTSTATUS Process();
+
+ //This routine is not required as the Transport Information is already
+ //provided into the CCapturePin but still using it to make the
+ //settings flexible
+ PBDA_TRANSPORT_INFO CaptureBdaTransportInfo ();
+
+ //This is the free callback from the bagged item (CCapturePin). If we
+ //do not provide a callback when we bag the CCapturePin, ExFreePool
+ //would be called. This is not desirable for C++ constructed objects.
+ //We merely delete the object here.
+ static void Cleanup (IN CCapturePin *Pin)
+ {
+ delete Pin;
+ }
+
+public:
+
+
+ //The capture pin's constructor. Initialize any non-0, non-NULL fields
+ //(since new will have zero'ed the memory anyway) and set up our
+ //device level pointers for access during capture routines.
+ CCapturePin (IN PKSPIN Pin);
+
+ //The capture pin's destructor.
+ ~CCapturePin ();
+
+ CSkyWalker1Device* GetDevice()
+ {
+ return m_Device;
+ }
+
+ //This is the capture sink notification mechanism for mapping completion.
+ //When the device DPC detects that a given number of mappings have been
+ //completed by the fake hardware, it signals the capture sink of this
+ //through this method.
+ virtual void ReleaseStream(IN ULONG ulStreamIndex);
+
+ //This is the creation dispatch for the capture pin. It creates
+ //the CCapturePin object and associates it with the AVStream object
+ //bagging it in the process.
+ static NTSTATUS PinCreate( IN OUT PKSPIN pKSPin,
+ IN PIRP pIoRequestPacket
+ );
+
+ //This is the set device state dispatch for the pin. The routine bridges
+ //to SetState() in the context of the CCapturePin.
+ static NTSTATUS DispatchSetState (
+ IN PKSPIN Pin,
+ IN KSSTATE ToState,
+ IN KSSTATE FromState
+ )
+ {
+ return
+ (reinterpret_cast(Pin->Context))->
+ SetState(ToState, FromState);
+ }
+
+ //This is the processing dispatch for the capture pin. The routine
+ //bridges to Process() in the context of the CCapturePin.
+ static NTSTATUS DispatchProcess (IN PKSPIN Pin)
+ {
+ return
+ (reinterpret_cast(Pin->Context))->Process();
+ }
+};
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
+
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CommonDef.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CommonDef.h
index bf9ec7d..8a47836 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CommonDef.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1CommonDef.h
@@ -1,149 +1,149 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1CommonDef.h
- Author :
- Date :
- Purpose : File to hold the common definitions for the Driver
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-#ifndef __SKYWALKER1_COMMON_DEF_H
-#define __SKYWALKER1_COMMON_DEF_H
-
-/* Include the Library and Other header file */
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-#define TUNER_MEM_TAG 'MNUT'
-#define CAPTURE_MEM_TAG 'MPAC'
-
-// Implementation GUID for SkyWalker1 Tuner and Capture
-// Must match the KSSTRING used in the installation INFs interface sections
-//Tuner Filter GUID {5C4E764F-AB43-46A9-B21E-8529C70F0A23}
-#define GUID_SKYWALKER_TUNER_FILTER\
- 0x5C4E764F, 0xAB43, 0x46A9, 0xB2, 0x1E, 0x85, 0x29, 0xC7, 0x0F, 0x0A, 0x23
-DEFINE_GUIDSTRUCT("5C4E764F-AB43-46A9-B21E-8529C70F0A23", SKYWALKER_TUNER_FILTER);
-#define SKYWALKER_TUNER_FILTER DEFINE_GUIDNAMED(SKYWALKER_TUNER_FILTER)
-
-//Capture Filter GUID {0F8F74D9-E524-4D05-BB60-F0C69ACB1756}
-#define GUID_SKYWALKER_CAPTURE_FILTER\
- 0x0F8F74D9, 0xE524, 0x4D05, 0xBB, 0x60, 0xF0, 0xC6, 0x9A, 0xCB, 0x17, 0x56
-DEFINE_GUIDSTRUCT("0F8F74D9-E524-4D05-BB60-F0C69ACB1756", SKYWALKER_CAPTURE_FILTER);
-// Defines the SKYWALKER_CAPTURE_FILTER as a GUID.
-#define SKYWALKER_CAPTURE_FILTER DEFINE_GUIDNAMED(SKYWALKER_CAPTURE_FILTER)
-
-//Medium GUID {2AEB4A94-FBB7-4FB1-8D74-243B91886EAB}
-#define GUID_SKYWALKER_TUNER_OUT_MEDIUM\
- 0x2AEB4A94, 0xFBB7, 0x4FB1, 0x8D, 0x74, 0x24, 0x3B, 0x91, 0x88, 0x6E, 0xAB
-DEFINE_GUIDSTRUCT("2AEB4A94-FBB7-4FB1-8D74-243B91886EAB", SKYWALKER_TUNER_OUT_MEDIUM);
-// Defines the SKYWALKER_TUNER_OUT_MEDIUM as a GUID.
-#define SKYWALKER_TUNER_OUT_MEDIUM DEFINE_GUIDNAMED(SKYWALKER_TUNER_OUT_MEDIUM)
-
-#define TRANSPORT_PACKET_SIZE 128 //188
-#define TRANSPORT_PACKET_COUNT 64 //512
-#define NUMBER_OF_FRAMES 8
-#define PACKET_PER_FRAME 2
-
-#define SYMBOL_RATE_MIN 1000
-#define SYMBOL_RATE_MAX 45000
-
-#define TUNER_FREQ_MIN 800000
-#define TUNER_FREQ_MAX 2250000
-
-#define IS_VALID(X) (((X)!=NULL)?true:false)
-
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-
-// Structure for the Tuner Parameters
-
-typedef struct _BDATUNER_DEVICE_PARAMETER
-{
- //Tuner Properties
- ULONG ulCarrierFrequency;
- ULONG ulFrequencyMultiplier;
- ULONG ulBandWidth;
- Polarisation Polarity;
- ULONG ulRange;
- ULONG ulTransponder;
-
- //LNB Parameters
- ULONG ulLnbLowLOFrequency;
- ULONG ulLnbHighLOFrequency;
- ULONG ulLnbSwitchFrequency;
-
- //Demodulator Properties
- ULONG ulInnerFecType;
- BinaryConvolutionCodeRate InnerFecRate;
- ULONG ulOuterFecType;
- BinaryConvolutionCodeRate OuterFecRate;
- ModulationType CurrentModulationType;
- TransmissionMode CurrentTransmissionMode;
- GuardInterval CurrentGuardInterval;
- SpectralInversion CurrentSpectralInversion;
- ULONG ulSymbolRate;
-
-} BDATUNER_DEVICE_PARAMETER, * PBDATUNER_DEVICE_PARAMETER;
-
-
-// Define a structure that represents the underlying device status.
-//
-typedef struct _BDATUNER_DEVICE_STATUS
-{
- //Tuner Status
- DWORD dwSignalStrength;
- DWORD dwSignalQuality;
- BOOLEAN fCarrierPresent;
-
- //Demodulator Status
- BOOLEAN fSignalLocked;
-} BDATUNER_DEVICE_STATUS, * PBDATUNER_DEVICE_STATUS;
-
-// ICaptureSink:
-//
-// This is a capture sink interface. The device level calls back the
-// CompleteMappings method passing the number of completed mappings for
-// the capture pin. This method is called during the device DPC.
-
-class ICaptureSink
-{
-public:
-
- virtual void ReleaseStream (IN ULONG ulStreamIndex) = 0;
-};
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-extern const BDA_FILTER_TEMPLATE TunerFilterTemplate;
-extern const BDA_FILTER_TEMPLATE SkyWalker1CaptureTemplate;
-extern const KSFILTER_DESCRIPTOR SkyWalker1TunerFilterDescriptor;
-extern const KSFILTER_DESCRIPTOR SkyWalker1CaptureFilterDescriptor;
-
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-typedef enum _HARDWARE_STATE {
-
- HardwareStopped = 0,
- HardwarePaused,
- HardwareRunning
-
-} HARDWARE_STATE, *PHARDWARE_STATE;
-
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
-#endif // __SKYWALKER1_COMMON_DEF_H
-
-
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1CommonDef.h
+ Author :
+ Date :
+ Purpose : File to hold the common definitions for the Driver
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+#ifndef __SKYWALKER1_COMMON_DEF_H
+#define __SKYWALKER1_COMMON_DEF_H
+
+/* Include the Library and Other header file */
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+#define TUNER_MEM_TAG 'MNUT'
+#define CAPTURE_MEM_TAG 'MPAC'
+
+// Implementation GUID for SkyWalker1 Tuner and Capture
+// Must match the KSSTRING used in the installation INFs interface sections
+//Tuner Filter GUID {5C4E764F-AB43-46A9-B21E-8529C70F0A23}
+#define GUID_SKYWALKER_TUNER_FILTER\
+ 0x5C4E764F, 0xAB43, 0x46A9, 0xB2, 0x1E, 0x85, 0x29, 0xC7, 0x0F, 0x0A, 0x23
+DEFINE_GUIDSTRUCT("5C4E764F-AB43-46A9-B21E-8529C70F0A23", SKYWALKER_TUNER_FILTER);
+#define SKYWALKER_TUNER_FILTER DEFINE_GUIDNAMED(SKYWALKER_TUNER_FILTER)
+
+//Capture Filter GUID {0F8F74D9-E524-4D05-BB60-F0C69ACB1756}
+#define GUID_SKYWALKER_CAPTURE_FILTER\
+ 0x0F8F74D9, 0xE524, 0x4D05, 0xBB, 0x60, 0xF0, 0xC6, 0x9A, 0xCB, 0x17, 0x56
+DEFINE_GUIDSTRUCT("0F8F74D9-E524-4D05-BB60-F0C69ACB1756", SKYWALKER_CAPTURE_FILTER);
+// Defines the SKYWALKER_CAPTURE_FILTER as a GUID.
+#define SKYWALKER_CAPTURE_FILTER DEFINE_GUIDNAMED(SKYWALKER_CAPTURE_FILTER)
+
+//Medium GUID {2AEB4A94-FBB7-4FB1-8D74-243B91886EAB}
+#define GUID_SKYWALKER_TUNER_OUT_MEDIUM\
+ 0x2AEB4A94, 0xFBB7, 0x4FB1, 0x8D, 0x74, 0x24, 0x3B, 0x91, 0x88, 0x6E, 0xAB
+DEFINE_GUIDSTRUCT("2AEB4A94-FBB7-4FB1-8D74-243B91886EAB", SKYWALKER_TUNER_OUT_MEDIUM);
+// Defines the SKYWALKER_TUNER_OUT_MEDIUM as a GUID.
+#define SKYWALKER_TUNER_OUT_MEDIUM DEFINE_GUIDNAMED(SKYWALKER_TUNER_OUT_MEDIUM)
+
+#define TRANSPORT_PACKET_SIZE 128 //188
+#define TRANSPORT_PACKET_COUNT 64 //512
+#define NUMBER_OF_FRAMES 8
+#define PACKET_PER_FRAME 2
+
+#define SYMBOL_RATE_MIN 1000
+#define SYMBOL_RATE_MAX 45000
+
+#define TUNER_FREQ_MIN 800000
+#define TUNER_FREQ_MAX 2250000
+
+#define IS_VALID(X) (((X)!=NULL)?true:false)
+
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+
+// Structure for the Tuner Parameters
+
+typedef struct _BDATUNER_DEVICE_PARAMETER
+{
+ //Tuner Properties
+ ULONG ulCarrierFrequency;
+ ULONG ulFrequencyMultiplier;
+ ULONG ulBandWidth;
+ Polarisation Polarity;
+ ULONG ulRange;
+ ULONG ulTransponder;
+
+ //LNB Parameters
+ ULONG ulLnbLowLOFrequency;
+ ULONG ulLnbHighLOFrequency;
+ ULONG ulLnbSwitchFrequency;
+
+ //Demodulator Properties
+ ULONG ulInnerFecType;
+ BinaryConvolutionCodeRate InnerFecRate;
+ ULONG ulOuterFecType;
+ BinaryConvolutionCodeRate OuterFecRate;
+ ModulationType CurrentModulationType;
+ TransmissionMode CurrentTransmissionMode;
+ GuardInterval CurrentGuardInterval;
+ SpectralInversion CurrentSpectralInversion;
+ ULONG ulSymbolRate;
+
+} BDATUNER_DEVICE_PARAMETER, * PBDATUNER_DEVICE_PARAMETER;
+
+
+// Define a structure that represents the underlying device status.
+//
+typedef struct _BDATUNER_DEVICE_STATUS
+{
+ //Tuner Status
+ DWORD dwSignalStrength;
+ DWORD dwSignalQuality;
+ BOOLEAN fCarrierPresent;
+
+ //Demodulator Status
+ BOOLEAN fSignalLocked;
+} BDATUNER_DEVICE_STATUS, * PBDATUNER_DEVICE_STATUS;
+
+// ICaptureSink:
+//
+// This is a capture sink interface. The device level calls back the
+// CompleteMappings method passing the number of completed mappings for
+// the capture pin. This method is called during the device DPC.
+
+class ICaptureSink
+{
+public:
+
+ virtual void ReleaseStream (IN ULONG ulStreamIndex) = 0;
+};
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+extern const BDA_FILTER_TEMPLATE TunerFilterTemplate;
+extern const BDA_FILTER_TEMPLATE SkyWalker1CaptureTemplate;
+extern const KSFILTER_DESCRIPTOR SkyWalker1TunerFilterDescriptor;
+extern const KSFILTER_DESCRIPTOR SkyWalker1CaptureFilterDescriptor;
+
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+typedef enum _HARDWARE_STATE {
+
+ HardwareStopped = 0,
+ HardwarePaused,
+ HardwareRunning
+
+} HARDWARE_STATE, *PHARDWARE_STATE;
+
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
+#endif // __SKYWALKER1_COMMON_DEF_H
+
+
+
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Control.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Control.h
index d1f9093..c08a792 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Control.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Control.h
@@ -1,127 +1,127 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Control.cpp
- Author :
- Date :
- Purpose : This File Holds the Device Control related declarations
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_CONTROL_H
-#define __SKYWALKER1_CONTROL_H
-
-/* Include the Library and Other header file */
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-
-/* gp8psk commands */
-
-/* Twinhan Vendor requests */
-#define TH_COMMAND_IN 0xC0
-#define TH_COMMAND_OUT 0xC1
-
-/* gp8psk commands */
-
-#define GET_8PSK_CONFIG 0x80 /* in */
-#define SET_8PSK_CONFIG 0x81
-#define I2C_WRITE 0x83
-#define I2C_READ 0x84
-#define ARM_TRANSFER 0x85
-#define TUNE_8PSK 0x86
-#define GET_SIGNAL_STRENGTH 0x87 /* in */
-#define LOAD_BCM4500 0x88
-#define BOOT_8PSK 0x89 /* in */
-#define START_INTERSIL 0x8A /* in */
-#define SET_LNB_VOLTAGE 0x8B
-#define SET_22KHZ_TONE 0x8C
-#define SEND_DISEQC_COMMAND 0x8D
-#define SET_DVB_MODE 0x8E
-#define SET_DN_SWITCH 0x8F
-#define GET_SIGNAL_LOCK 0x90 /* in */
-#define GET_SERIAL_NUMBER 0x93 /* in */
-#define USE_EXTRA_VOLT 0x94
-#define CW3K_INIT 0x9d
-
-/* PSK_configuration bits */
-#define bm8pskStarted 0x01
-#define bm8pskFW_Loaded 0x02
-#define bmIntersilOn 0x04
-#define bmDVBmode 0x08
-#define bm22kHz 0x10
-#define bmSEL18V 0x20
-#define bmDCtuned 0x40
-#define bmArmed 0x80
-
-/* Satellite modulation modes */
-#define ADV_MOD_DVB_QPSK 0 /* DVB-S QPSK */
-#define ADV_MOD_TURBO_QPSK 1 /* Turbo QPSK */
-#define ADV_MOD_TURBO_8PSK 2 /* Turbo 8PSK (also used for Trellis 8PSK) */
-#define ADV_MOD_TURBO_16QAM 3 /* Turbo 16QAM (also used for Trellis 8PSK) */
-
-#define ADV_MOD_DCII_C_QPSK 4 /* Digicipher II Combo */
-#define ADV_MOD_DCII_I_QPSK 5 /* Digicipher II I-stream */
-#define ADV_MOD_DCII_Q_QPSK 6 /* Digicipher II Q-stream */
-#define ADV_MOD_DCII_C_OQPSK 7 /* Digicipher II offset QPSK */
-#define ADV_MOD_DSS_QPSK 8 /* DSS (DIRECTV) QPSK */
-#define ADV_MOD_DVB_BPSK 9 /* DVB-S BPSK */
-
-#define GET_USB_SPEED 0x07
-#define USB_SPEED_LOW 0
-#define USB_SPEED_FULL 1
-#define USB_SPEED_HIGH 2
-
-#define RESET_FX2 0x13
-
-#define FW_VERSION_READ 0x0B
-#define VENDOR_STRING_READ 0x0C
-#define PRODUCT_STRING_READ 0x0D
-#define FW_BCD_VERSION_READ 0x14
-
-#define SEC_VOLTAGE_13 0
-#define SEC_VOLTAGE_18 1
-
-#define SEC_TONE_ON 0
-#define SEC_TONE_OFF 1
-
-#define SWITCH_ON_TUNER 1
-#define SWITCH_OFF_TUNER 0
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-NTSTATUS GetSignalStatus( IN PKSDEVICE pKSDeviceObject,
- OUT PBOOLEAN pbSignalLockStatus
- );
-NTSTATUS ReadTunerSignalStrength( IN PKSDEVICE pKSDeviceObject,
- OUT PULONG pulSigStrength
- );
-NTSTATUS SetLnbVoltage(IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucVoltage);
-NTSTATUS TuneDevice(IN PKSDEVICE pKSDeviceObject,
- IN PBDATUNER_DEVICE_PARAMETER pDeviceParameter);
-NTSTATUS SetupTunerPower( IN PKSDEVICE pKSDeviceObject,
- IN BOOLEAN bOnOff);
-NTSTATUS SetStreamingControl( IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucOnOff);
-NTSTATUS SetTunerTone( IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucTone);
-NTSTATUS ConfigureTuner(IN PKSDEVICE pKSDeviceObject,
- IN PBDATUNER_DEVICE_PARAMETER pNewConfiguration);
-NTSTATUS DiseqcCommand( IN PKSDEVICE pKSDeviceObject,
- IN PDISEQC_COMMAND pCommand);
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1Control.cpp
+ Author :
+ Date :
+ Purpose : This File Holds the Device Control related declarations
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_CONTROL_H
+#define __SKYWALKER1_CONTROL_H
+
+/* Include the Library and Other header file */
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+
+/* gp8psk commands */
+
+/* Twinhan Vendor requests */
+#define TH_COMMAND_IN 0xC0
+#define TH_COMMAND_OUT 0xC1
+
+/* gp8psk commands */
+
+#define GET_8PSK_CONFIG 0x80 /* in */
+#define SET_8PSK_CONFIG 0x81
+#define I2C_WRITE 0x83
+#define I2C_READ 0x84
+#define ARM_TRANSFER 0x85
+#define TUNE_8PSK 0x86
+#define GET_SIGNAL_STRENGTH 0x87 /* in */
+#define LOAD_BCM4500 0x88
+#define BOOT_8PSK 0x89 /* in */
+#define START_INTERSIL 0x8A /* in */
+#define SET_LNB_VOLTAGE 0x8B
+#define SET_22KHZ_TONE 0x8C
+#define SEND_DISEQC_COMMAND 0x8D
+#define SET_DVB_MODE 0x8E
+#define SET_DN_SWITCH 0x8F
+#define GET_SIGNAL_LOCK 0x90 /* in */
+#define GET_SERIAL_NUMBER 0x93 /* in */
+#define USE_EXTRA_VOLT 0x94
+#define CW3K_INIT 0x9d
+
+/* PSK_configuration bits */
+#define bm8pskStarted 0x01
+#define bm8pskFW_Loaded 0x02
+#define bmIntersilOn 0x04
+#define bmDVBmode 0x08
+#define bm22kHz 0x10
+#define bmSEL18V 0x20
+#define bmDCtuned 0x40
+#define bmArmed 0x80
+
+/* Satellite modulation modes */
+#define ADV_MOD_DVB_QPSK 0 /* DVB-S QPSK */
+#define ADV_MOD_TURBO_QPSK 1 /* Turbo QPSK */
+#define ADV_MOD_TURBO_8PSK 2 /* Turbo 8PSK (also used for Trellis 8PSK) */
+#define ADV_MOD_TURBO_16QAM 3 /* Turbo 16QAM (also used for Trellis 8PSK) */
+
+#define ADV_MOD_DCII_C_QPSK 4 /* Digicipher II Combo */
+#define ADV_MOD_DCII_I_QPSK 5 /* Digicipher II I-stream */
+#define ADV_MOD_DCII_Q_QPSK 6 /* Digicipher II Q-stream */
+#define ADV_MOD_DCII_C_OQPSK 7 /* Digicipher II offset QPSK */
+#define ADV_MOD_DSS_QPSK 8 /* DSS (DIRECTV) QPSK */
+#define ADV_MOD_DVB_BPSK 9 /* DVB-S BPSK */
+
+#define GET_USB_SPEED 0x07
+#define USB_SPEED_LOW 0
+#define USB_SPEED_FULL 1
+#define USB_SPEED_HIGH 2
+
+#define RESET_FX2 0x13
+
+#define FW_VERSION_READ 0x0B
+#define VENDOR_STRING_READ 0x0C
+#define PRODUCT_STRING_READ 0x0D
+#define FW_BCD_VERSION_READ 0x14
+
+#define SEC_VOLTAGE_13 0
+#define SEC_VOLTAGE_18 1
+
+#define SEC_TONE_ON 0
+#define SEC_TONE_OFF 1
+
+#define SWITCH_ON_TUNER 1
+#define SWITCH_OFF_TUNER 0
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+NTSTATUS GetSignalStatus( IN PKSDEVICE pKSDeviceObject,
+ OUT PBOOLEAN pbSignalLockStatus
+ );
+NTSTATUS ReadTunerSignalStrength( IN PKSDEVICE pKSDeviceObject,
+ OUT PULONG pulSigStrength
+ );
+NTSTATUS SetLnbVoltage(IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucVoltage);
+NTSTATUS TuneDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PBDATUNER_DEVICE_PARAMETER pDeviceParameter);
+NTSTATUS SetupTunerPower( IN PKSDEVICE pKSDeviceObject,
+ IN BOOLEAN bOnOff);
+NTSTATUS SetStreamingControl( IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucOnOff);
+NTSTATUS SetTunerTone( IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucTone);
+NTSTATUS ConfigureTuner(IN PKSDEVICE pKSDeviceObject,
+ IN PBDATUNER_DEVICE_PARAMETER pNewConfiguration);
+NTSTATUS DiseqcCommand( IN PKSDEVICE pKSDeviceObject,
+ IN PDISEQC_COMMAND pCommand);
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_CONTROL_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Device.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Device.h
index e53f9f7..3d1a67e 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Device.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Device.h
@@ -1,187 +1,187 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Device.h
- Author :
- Date :
- Purpose : Main Skywalker Device level Implementation
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef SKYWALKER1_TUNER_DEVICE_H
-#define SKYWALKER1_TUNER_DEVICE_H
-
-/* Include the Library and Other header file */
-#include "SkyWalker1USB.h"
-#include "SkyWalker1Extended.h"
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-
-//The SkyWalker1 Device class.
-class CSkyWalker1Device
-{
-public:
-
- //Device Initialization and Dispatch Related definitions
- NTSTATUS Create(IN PKSDEVICE pKSDeviceObject);
- NTSTATUS Start(
- IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIrp,
- IN PCM_RESOURCE_LIST pResourceList OPTIONAL,
- IN PCM_RESOURCE_LIST pTranslatedResourceList OPTIONAL
- );
-
- NTSTATUS Stop( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-
- NTSTATUS Close( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
- NTSTATUS SetPower(
- IN PKSDEVICE pKSDeviceObject, //Pointer to the device object
- //provided by the system.
- IN PIRP pIoRequestPacket,//Pointer to the IRP related to this request.
- IN DEVICE_POWER_STATE To, //Requested power state.
- IN DEVICE_POWER_STATE From //Current power state.
- );
-
- NTSTATUS InitializeTuner( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-
- // Device access related Function definitions
- // An instance of the filter uses these functions
- // to manage resources on the device.
-
- NTSTATUS Acquire(IN PBDATUNER_DEVICE_PARAMETER pNewResource,
- OUT PULONG pulAcquiredResourceID);
-
- NTSTATUS Update( IN PBDATUNER_DEVICE_PARAMETER pNewResource,
- IN ULONG ulResourceID);
-
- NTSTATUS SendDiseqcCommand(
- IN PDISEQC_COMMAND pDiseqcCommand,
- IN ULONG ulResourceID
- );
-
- NTSTATUS Release(IN ULONG ulResourceID);
-
- NTSTATUS GetStatus(PBDATUNER_DEVICE_STATUS pDeviceStatus);
-
- //DMA Adapter related Functions
- NTSTATUS InitializeAdapterStream(IN PKSDEVICE pKSDeviceObject);
-
- //Stream Capture Related Fuctions
- NTSTATUS SetupCaptureSink (
- IN ICaptureSink * pCapturePin,
- IN PBDA_TRANSPORT_INFO TransportInfo
- );
- void RemoveCaptureSink ();
-
- NTSTATUS StartStream ();
- NTSTATUS PauseStream (IN BOOLEAN Pausing);
- NTSTATUS StopStream ();
- NTSTATUS ReadStream(IN ULONG ulStreamIndex);
- void ProcessStream(IN ULONG ulStreamIndex);
-
- BOOLEAN TimeToReadSignalStatus(void);
-
- PKSDEVICE m_pKSDevice;
-
- //USB Related definitions
- USB_DEVICE_DESCRIPTOR USBDeviceDescriptor;
- USBD_PIPE_INFORMATION ReadPipe;
- USBD_PIPE_INFORMATION WritePipe;
- USBSTATE UsbDeviceState;
- USBSTATE PreviousUsbDeviceState;
- //Pending I/O queue state
- QUEUE_STATE QueueState;
-
- //obtain and hold this lock while changing the device state,
- //the queue state and while processing the queue.
- KSPIN_LOCK DeviceStateLock;
- //Current Usb Irp
- PIRP pUsbStreamIrp[PACKET_PER_FRAME * NUMBER_OF_FRAMES];
- //Device Stop Event
- KEVENT EvDeviceStopOk;
- //Device Remove Event
- KEVENT EvDeviceRemoveOk;
- //Outstanding IO Count for the Driver
- ULONG ulOutStandingIoCount;
- //Outstanding IO Count Lock
- KSPIN_LOCK kIoCountLock;
-
- PDMA_ADAPTER m_pDMAAdapter;
-
- ULONG m_SampleSize;
-
- //Temporary Bytes Read Counter
- ULONG m_NumberOfBytesRead[NUMBER_OF_FRAMES];
-
- PUCHAR GetSynthBuffer(ULONG ulStreamIndex)
- {
- return m_SynthesisBuffer[ulStreamIndex];
- }
-
-private:
-
- ULONG m_ulDeviceInstance;
- BDATUNER_DEVICE_PARAMETER m_CurResource;
- BDATUNER_DEVICE_STATUS m_TunerStatus;
- ULONG m_ulCurResourceID;
- ULONG m_ulcResourceUsers;
- LARGE_INTEGER m_PreviousStatusReadTime;
-
- //The synthesis buffer. This is a private buffer we use to store the
- //references of the Streaming Data.It is used for the Reading data
- //from the device and also Copying Data to the Stream Buffer sent
- //by the application
- PUCHAR m_SynthesisBuffer[NUMBER_OF_FRAMES];
-
- //Key information regarding the frames we generate.
- LONGLONG m_TimePerFrame;
- ULONG m_PacketSize;
- ULONG m_PacketsPerSample;
-
- //The current state of the Device
- HARDWARE_STATE m_HardwareState;
-
- //The pause / stop hardware flag and event.
- BOOLEAN m_StopHardware;
- KEVENT m_HardwareEvent;
-
- //Number of pins with resources acquired. This is used as a locking
- //mechanism for resource acquisition on the device.
- LONG m_PinsWithResources;
-
- //The capture sink. When we complete stream reading, we
- //notify the capture sink.
- ICaptureSink *m_CaptureSink;
-
- //The video info header we're basing hardware settings on. The pin
- //provides this to us when acquiring resources and must guarantee its
- //stability until resources are released.
- PBDA_TRANSPORT_INFO m_TransportInfo;
-};
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
-#endif /*SKYWALKER1_TUNER_DEVICE_H*/
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1Device.h
+ Author :
+ Date :
+ Purpose : Main Skywalker Device level Implementation
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef SKYWALKER1_TUNER_DEVICE_H
+#define SKYWALKER1_TUNER_DEVICE_H
+
+/* Include the Library and Other header file */
+#include "SkyWalker1USB.h"
+#include "SkyWalker1Extended.h"
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+
+//The SkyWalker1 Device class.
+class CSkyWalker1Device
+{
+public:
+
+ //Device Initialization and Dispatch Related definitions
+ NTSTATUS Create(IN PKSDEVICE pKSDeviceObject);
+ NTSTATUS Start(
+ IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIrp,
+ IN PCM_RESOURCE_LIST pResourceList OPTIONAL,
+ IN PCM_RESOURCE_LIST pTranslatedResourceList OPTIONAL
+ );
+
+ NTSTATUS Stop( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+
+ NTSTATUS Close( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+ NTSTATUS SetPower(
+ IN PKSDEVICE pKSDeviceObject, //Pointer to the device object
+ //provided by the system.
+ IN PIRP pIoRequestPacket,//Pointer to the IRP related to this request.
+ IN DEVICE_POWER_STATE To, //Requested power state.
+ IN DEVICE_POWER_STATE From //Current power state.
+ );
+
+ NTSTATUS InitializeTuner( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+
+ // Device access related Function definitions
+ // An instance of the filter uses these functions
+ // to manage resources on the device.
+
+ NTSTATUS Acquire(IN PBDATUNER_DEVICE_PARAMETER pNewResource,
+ OUT PULONG pulAcquiredResourceID);
+
+ NTSTATUS Update( IN PBDATUNER_DEVICE_PARAMETER pNewResource,
+ IN ULONG ulResourceID);
+
+ NTSTATUS SendDiseqcCommand(
+ IN PDISEQC_COMMAND pDiseqcCommand,
+ IN ULONG ulResourceID
+ );
+
+ NTSTATUS Release(IN ULONG ulResourceID);
+
+ NTSTATUS GetStatus(PBDATUNER_DEVICE_STATUS pDeviceStatus);
+
+ //DMA Adapter related Functions
+ NTSTATUS InitializeAdapterStream(IN PKSDEVICE pKSDeviceObject);
+
+ //Stream Capture Related Fuctions
+ NTSTATUS SetupCaptureSink (
+ IN ICaptureSink * pCapturePin,
+ IN PBDA_TRANSPORT_INFO TransportInfo
+ );
+ void RemoveCaptureSink ();
+
+ NTSTATUS StartStream ();
+ NTSTATUS PauseStream (IN BOOLEAN Pausing);
+ NTSTATUS StopStream ();
+ NTSTATUS ReadStream(IN ULONG ulStreamIndex);
+ void ProcessStream(IN ULONG ulStreamIndex);
+
+ BOOLEAN TimeToReadSignalStatus(void);
+
+ PKSDEVICE m_pKSDevice;
+
+ //USB Related definitions
+ USB_DEVICE_DESCRIPTOR USBDeviceDescriptor;
+ USBD_PIPE_INFORMATION ReadPipe;
+ USBD_PIPE_INFORMATION WritePipe;
+ USBSTATE UsbDeviceState;
+ USBSTATE PreviousUsbDeviceState;
+ //Pending I/O queue state
+ QUEUE_STATE QueueState;
+
+ //obtain and hold this lock while changing the device state,
+ //the queue state and while processing the queue.
+ KSPIN_LOCK DeviceStateLock;
+ //Current Usb Irp
+ PIRP pUsbStreamIrp[PACKET_PER_FRAME * NUMBER_OF_FRAMES];
+ //Device Stop Event
+ KEVENT EvDeviceStopOk;
+ //Device Remove Event
+ KEVENT EvDeviceRemoveOk;
+ //Outstanding IO Count for the Driver
+ ULONG ulOutStandingIoCount;
+ //Outstanding IO Count Lock
+ KSPIN_LOCK kIoCountLock;
+
+ PDMA_ADAPTER m_pDMAAdapter;
+
+ ULONG m_SampleSize;
+
+ //Temporary Bytes Read Counter
+ ULONG m_NumberOfBytesRead[NUMBER_OF_FRAMES];
+
+ PUCHAR GetSynthBuffer(ULONG ulStreamIndex)
+ {
+ return m_SynthesisBuffer[ulStreamIndex];
+ }
+
+private:
+
+ ULONG m_ulDeviceInstance;
+ BDATUNER_DEVICE_PARAMETER m_CurResource;
+ BDATUNER_DEVICE_STATUS m_TunerStatus;
+ ULONG m_ulCurResourceID;
+ ULONG m_ulcResourceUsers;
+ LARGE_INTEGER m_PreviousStatusReadTime;
+
+ //The synthesis buffer. This is a private buffer we use to store the
+ //references of the Streaming Data.It is used for the Reading data
+ //from the device and also Copying Data to the Stream Buffer sent
+ //by the application
+ PUCHAR m_SynthesisBuffer[NUMBER_OF_FRAMES];
+
+ //Key information regarding the frames we generate.
+ LONGLONG m_TimePerFrame;
+ ULONG m_PacketSize;
+ ULONG m_PacketsPerSample;
+
+ //The current state of the Device
+ HARDWARE_STATE m_HardwareState;
+
+ //The pause / stop hardware flag and event.
+ BOOLEAN m_StopHardware;
+ KEVENT m_HardwareEvent;
+
+ //Number of pins with resources acquired. This is used as a locking
+ //mechanism for resource acquisition on the device.
+ LONG m_PinsWithResources;
+
+ //The capture sink. When we complete stream reading, we
+ //notify the capture sink.
+ ICaptureSink *m_CaptureSink;
+
+ //The video info header we're basing hardware settings on. The pin
+ //provides this to us when acquiring resources and must guarantee its
+ //stability until resources are released.
+ PBDA_TRANSPORT_INFO m_TransportInfo;
+};
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
+#endif /*SKYWALKER1_TUNER_DEVICE_H*/
+
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Extended.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Extended.h
index 047d686..7c16ee8 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Extended.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Extended.h
@@ -1,109 +1,109 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1AntennaPin.h
- Author :
- Date :
- Purpose : This File Holds the Extended BDA Definitions
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_EXTENDED_H
-#define __SKYWALKER1_EXTENDED_H
-
-/* Include the Library and Other header file */
-#if !defined(_KSMEDIA_)
-#error KSMEDIA.H must be included before BDAMEDIA.H
-#endif // !defined(_KSMEDIA_)
-
-#if !defined(_BDATYPES_)
-#error BDATYPES.H must be included before BDAMEDIA.H
-#endif // !defined(_BDATYPES_)
-
-#if !defined(_BDAMEDIA_)
-#define _BDAMEDIA_
-#endif // !defined(_BDAMEDIA_)
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-
-#define MAX_DISEQC_COMMAND_LENGTH 6
-
-/* Extended Property*/
-
-//Used to extend the feature of the BDA
-//{0B5221EB-F4C4-4976-B959-EF74427464D9}
-#define STATIC_KSPROPSETID_BdaExtendedProperty \
- 0x0B5221EB, 0xF4C4, 0x4976, 0xB9, 0x59, 0xEF, 0x74, 0x42, 0x74, 0x64, 0xD9
-DEFINE_GUIDSTRUCT("0B5221EB-F4C4-4976-B959-EF74427464D9", KSPROPSETID_BdaExtendedProperty);
-#define KSPROPSETID_BdaExtendedProperty DEFINE_GUIDNAMED(KSPROPSETID_BdaExtendedProperty)
-
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-//Extended Property List
-typedef enum __KSPROPERTY_EXTENDED
-{
- /* DiSEqC Command */
- //Used to send the Digital Sattelite Equipment Control (DiSEqC)
- //Commands by application
- KSPROPERTY_BDA_DISEQC = 0, //Extension Property 1
-
- //Add New Extended Commands Here
-
-}KSPROPERTY_EXTENDED;
-
-//Enumeration can be used during Simple Tone Burst Command
-typedef enum enSimpleToneBurst
-{
- SEC_MINI_A,
- SEC_MINI_B
-}SIMPLE_TONE_BURST;
-
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-//DiSEqC Command related Structure definitions
-typedef struct __DISEQC_COMMAND
-{
- UCHAR ucMessage[MAX_DISEQC_COMMAND_LENGTH]; /*
- Byte - 0 : Framing,
- Byte - 1 : Address,
- Byte - 2 : Command,
- Byte - 3 : Data[0],
- Byte - 4 : Data[1],
- Byte - 5 : Data[2]
- */
- UCHAR ucMessageLength;/* The Valid values for DiSEqC Command are 3...6
- If this value is 1 then the Byte 0 is taken as Simple "Tone Burst" Control
- Command */
-
-}DISEQC_COMMAND,*PDISEQC_COMMAND;
-
-//Property that will be used to send the Diseqc command by the application
-#define DEFINE_KSPROPERTY_ITEM_BDA_DISEQC(GetHandler, SetHandler)\
- DEFINE_KSPROPERTY_ITEM(\
- KSPROPERTY_BDA_DISEQC,\
- (GetHandler),\
- sizeof(KSP_NODE),\
- sizeof(DISEQC_COMMAND),\
- (SetHandler),\
- NULL, 0, NULL, NULL, 0)
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1AntennaPin.h
+ Author :
+ Date :
+ Purpose : This File Holds the Extended BDA Definitions
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_EXTENDED_H
+#define __SKYWALKER1_EXTENDED_H
+
+/* Include the Library and Other header file */
+#if !defined(_KSMEDIA_)
+#error KSMEDIA.H must be included before BDAMEDIA.H
+#endif // !defined(_KSMEDIA_)
+
+#if !defined(_BDATYPES_)
+#error BDATYPES.H must be included before BDAMEDIA.H
+#endif // !defined(_BDATYPES_)
+
+#if !defined(_BDAMEDIA_)
+#define _BDAMEDIA_
+#endif // !defined(_BDAMEDIA_)
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+
+#define MAX_DISEQC_COMMAND_LENGTH 6
+
+/* Extended Property*/
+
+//Used to extend the feature of the BDA
+//{0B5221EB-F4C4-4976-B959-EF74427464D9}
+#define STATIC_KSPROPSETID_BdaExtendedProperty \
+ 0x0B5221EB, 0xF4C4, 0x4976, 0xB9, 0x59, 0xEF, 0x74, 0x42, 0x74, 0x64, 0xD9
+DEFINE_GUIDSTRUCT("0B5221EB-F4C4-4976-B959-EF74427464D9", KSPROPSETID_BdaExtendedProperty);
+#define KSPROPSETID_BdaExtendedProperty DEFINE_GUIDNAMED(KSPROPSETID_BdaExtendedProperty)
+
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+//Extended Property List
+typedef enum __KSPROPERTY_EXTENDED
+{
+ /* DiSEqC Command */
+ //Used to send the Digital Sattelite Equipment Control (DiSEqC)
+ //Commands by application
+ KSPROPERTY_BDA_DISEQC = 0, //Extension Property 1
+
+ //Add New Extended Commands Here
+
+}KSPROPERTY_EXTENDED;
+
+//Enumeration can be used during Simple Tone Burst Command
+typedef enum enSimpleToneBurst
+{
+ SEC_MINI_A,
+ SEC_MINI_B
+}SIMPLE_TONE_BURST;
+
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+//DiSEqC Command related Structure definitions
+typedef struct __DISEQC_COMMAND
+{
+ UCHAR ucMessage[MAX_DISEQC_COMMAND_LENGTH]; /*
+ Byte - 0 : Framing,
+ Byte - 1 : Address,
+ Byte - 2 : Command,
+ Byte - 3 : Data[0],
+ Byte - 4 : Data[1],
+ Byte - 5 : Data[2]
+ */
+ UCHAR ucMessageLength;/* The Valid values for DiSEqC Command are 3...6
+ If this value is 1 then the Byte 0 is taken as Simple "Tone Burst" Control
+ Command */
+
+}DISEQC_COMMAND,*PDISEQC_COMMAND;
+
+//Property that will be used to send the Diseqc command by the application
+#define DEFINE_KSPROPERTY_ITEM_BDA_DISEQC(GetHandler, SetHandler)\
+ DEFINE_KSPROPERTY_ITEM(\
+ KSPROPERTY_BDA_DISEQC,\
+ (GetHandler),\
+ sizeof(KSP_NODE),\
+ sizeof(DISEQC_COMMAND),\
+ (SetHandler),\
+ NULL, 0, NULL, NULL, 0)
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_EXTENDED_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Main.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Main.h
index a072e07..7f2c8e0 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Main.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Main.h
@@ -1,69 +1,69 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Main.h
- Author :
- Date :
- Purpose : Entry point for the Driver
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_MAIN_H
-#define __SKYWALKER1_MAIN_H
-
-/* Include the Library and Other header file */
-#include
-#include
-#include //Kernel Streaming Driver
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include "SkyWalker1AntennaPin.h"
-#include "SkyWalker1CaptureFilter.h"
-#include "SkyWalker1CapturePin.h"
-#include "SkyWalker1CommonDef.h"
-#include "SkyWalker1Control.h"
-#include "SkyWalker1Device.h"
-#include "SkyWalker1TransportPin.h"
-#include "SkyWalker1TunerFilter.h"
-#include "SkyWalker1TunerPin.h"
-#include "SkyWalker1Extended.h"
-
-extern "C"
-{
-#include //For the Mutex
-#include //For the WCHAR and swprintf
-#include //For sprintf() function
-
-#include "SkyWalker1PnP.h" //Header for the PnP related definitions
-#include "SkyWalker1USB.h"
-#include "SkyWalker1Utility.h"
-
-}
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1Main.h
+ Author :
+ Date :
+ Purpose : Entry point for the Driver
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_MAIN_H
+#define __SKYWALKER1_MAIN_H
+
+/* Include the Library and Other header file */
+#include
+#include
+#include //Kernel Streaming Driver
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include "SkyWalker1AntennaPin.h"
+#include "SkyWalker1CaptureFilter.h"
+#include "SkyWalker1CapturePin.h"
+#include "SkyWalker1CommonDef.h"
+#include "SkyWalker1Control.h"
+#include "SkyWalker1Device.h"
+#include "SkyWalker1TransportPin.h"
+#include "SkyWalker1TunerFilter.h"
+#include "SkyWalker1TunerPin.h"
+#include "SkyWalker1Extended.h"
+
+extern "C"
+{
+#include //For the Mutex
+#include //For the WCHAR and swprintf
+#include //For sprintf() function
+
+#include "SkyWalker1PnP.h" //Header for the PnP related definitions
+#include "SkyWalker1USB.h"
+#include "SkyWalker1Utility.h"
+
+}
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_MAIN_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1PnP.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1PnP.h
index 1b54c69..44e7851 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1PnP.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1PnP.h
@@ -1,56 +1,56 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1PnP.h
- Author :
- Date :
- Purpose : PnP IRP Message Handler
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-#ifndef __SKYWALKER1_PNP_H
-#define __SKYWALKER1_PNP_H
-
-/* Include the Library and Other header file */
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-NTSTATUS SkyWalker1AddDevice(IN PKSDEVICE pKSDeviceObject);
-VOID SkyWalker1Remove( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS SkyWalker1Start(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket,
- IN PCM_RESOURCE_LIST pResourceList,
- IN PCM_RESOURCE_LIST pCIResourceListTranslated);
-VOID SkyWalker1Stop(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS SkyWalker1QueryStop( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-VOID SkyWalker1SetPower
-(
- IN PKSDEVICE pKSDeviceObject, //Pointer to the device object
- //provided by the system.
- IN PIRP pIoRequestPacket, //Pointer to the IRP related to this request.
- IN DEVICE_POWER_STATE To, //Requested power state.
- IN DEVICE_POWER_STATE From //Current power state.
-);
-/* End of Function prototype definitions */
-
-#endif // __SKYWALKER1_PNP_H
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1PnP.h
+ Author :
+ Date :
+ Purpose : PnP IRP Message Handler
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+#ifndef __SKYWALKER1_PNP_H
+#define __SKYWALKER1_PNP_H
+
+/* Include the Library and Other header file */
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+NTSTATUS SkyWalker1AddDevice(IN PKSDEVICE pKSDeviceObject);
+VOID SkyWalker1Remove( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS SkyWalker1Start(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket,
+ IN PCM_RESOURCE_LIST pResourceList,
+ IN PCM_RESOURCE_LIST pCIResourceListTranslated);
+VOID SkyWalker1Stop(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS SkyWalker1QueryStop( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+VOID SkyWalker1SetPower
+(
+ IN PKSDEVICE pKSDeviceObject, //Pointer to the device object
+ //provided by the system.
+ IN PIRP pIoRequestPacket, //Pointer to the IRP related to this request.
+ IN DEVICE_POWER_STATE To, //Requested power state.
+ IN DEVICE_POWER_STATE From //Current power state.
+);
+/* End of Function prototype definitions */
+
+#endif // __SKYWALKER1_PNP_H
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TransportPin.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TransportPin.h
index 5a4ab97..37d6599 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TransportPin.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TransportPin.h
@@ -1,84 +1,84 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1TransportPin.h
- Author :
- Date :
- Purpose : This file contains header for the Transport pin on the Tuner
- filter.
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_TRANSPORT_PIN_H
-#define __SKYWALKER1_TRANSPORT_PIN_H
-
-/* Include the Library and Other header file */
-//#include "SkyWalker1CommonDef.h"
-#include "SkyWalker1TunerPin.h"
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-//The Trasport Pin class.
-class CTransportPin : public CTunerPin
-{
-public:
-
-
- //Define a data intersection handler function for the
- //pin (KSPIN_DESCRIPTOR_EX structure).
- //Network provider and AVStream use this function
- //to connect the output pin with a downstream filter.
- static NTSTATUS IntersectDataFormat(
- IN PVOID pContext,
- IN PIRP pIoRequestPacket,
- IN PKSP_PIN Pin,
- IN PKSDATARANGE DataRange,
- IN PKSDATARANGE MatchingDataRange,
- IN ULONG DataBufferSize,
- OUT PVOID Data OPTIONAL,
- OUT PULONG DataSize
- );
-
- static NTSTATUS GetDigitalDemodProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
- static NTSTATUS SetDigitalDemodProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
- //Function to send the Extended BDA Commands to the Tuner
- static NTSTATUS SetExtendedProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-};
-
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1TransportPin.h
+ Author :
+ Date :
+ Purpose : This file contains header for the Transport pin on the Tuner
+ filter.
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_TRANSPORT_PIN_H
+#define __SKYWALKER1_TRANSPORT_PIN_H
+
+/* Include the Library and Other header file */
+//#include "SkyWalker1CommonDef.h"
+#include "SkyWalker1TunerPin.h"
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+//The Trasport Pin class.
+class CTransportPin : public CTunerPin
+{
+public:
+
+
+ //Define a data intersection handler function for the
+ //pin (KSPIN_DESCRIPTOR_EX structure).
+ //Network provider and AVStream use this function
+ //to connect the output pin with a downstream filter.
+ static NTSTATUS IntersectDataFormat(
+ IN PVOID pContext,
+ IN PIRP pIoRequestPacket,
+ IN PKSP_PIN Pin,
+ IN PKSDATARANGE DataRange,
+ IN PKSDATARANGE MatchingDataRange,
+ IN ULONG DataBufferSize,
+ OUT PVOID Data OPTIONAL,
+ OUT PULONG DataSize
+ );
+
+ static NTSTATUS GetDigitalDemodProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+ static NTSTATUS SetDigitalDemodProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+ //Function to send the Extended BDA Commands to the Tuner
+ static NTSTATUS SetExtendedProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+};
+
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_TRANSPORT_PIN_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerFilter.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerFilter.h
index 2993d68..dd7c026 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerFilter.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerFilter.h
@@ -1,140 +1,140 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1TunerFilter.h
- Author :
- Date :
- Purpose : Tuner Filter Class Definition
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef SKYWALKER1_TUNER_FILTER_H
-#define SKYWALKER1_TUNER_FILTER_H
-
-/* Include the Library and Other header file */
-#include "SkyWalker1CommonDef.h"
-#include "SkyWalker1Device.h"
-#include "SkyWalker1Extended.h"
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-//The Tuner Filter class.
-class CTunerFilter
-{
-public:
-
- //Functions to Create and Close Filter
- static NTSTATUS Create( IN OUT PKSFILTER pKSFilter,
- IN PIRP pIoRequestPacket);
-
- static NTSTATUS FilterClose( IN OUT PKSFILTER pKSFilter,
- IN PIRP pIoRequestPacket);
-
- //KSMETHODSETID_BdaChangeSync pKSFilter change sync methods
- static NTSTATUS StartChanges( IN PIRP pIoRequestPacket,
- IN PKSMETHOD pKSMethod,
- OPTIONAL PVOID pvIgnored);
-
- static NTSTATUS CheckChanges( IN PIRP pIoRequestPacket,
- IN PKSMETHOD pKSMethod,
- OPTIONAL PVOID pvIgnored);
-
- static NTSTATUS CommitChanges( IN PIRP pIoRequestPacket,
- IN PKSMETHOD pKSMethod,
- OPTIONAL PVOID pvIgnored);
-
- static NTSTATUS GetChangeState( IN PIRP pIoRequestPacket,
- IN PKSMETHOD pKSMethod,
- OUT PULONG pulChangeState);
-
-
- //KSMETHODSETID_BdaDeviceConfiguration Method to modify filter topology.
- static NTSTATUS CreateTopology( IN PIRP pIoRequestPacket,
- IN PKSMETHOD pKSMethod,
- OPTIONAL PVOID pvIgnored);
-
-
- //pKSFilter Implementation Methods
- (class CSkyWalker1Device *) GetDevice()
- {
- return m_pDevice;
- };
-
- NTSTATUS SetDeviceState(KSSTATE NewKsState)
- {
- m_KsState = NewKsState;
- return STATUS_SUCCESS;
- };
-
-
- //Tuner Node Properties
- NTSTATUS GetTunerProperty(OUT PBDATUNER_DEVICE_PARAMETER pTunerParameter);
- NTSTATUS SetFrequency(IN ULONG ulBdaParameter);
- NTSTATUS SetMultiplier(IN ULONG ulBdaParameter);
- NTSTATUS SetBandwidth(IN ULONG ulBdaParameter);
- NTSTATUS SetPolarity(IN Polarisation NewPolarity);
- NTSTATUS SetRange(IN ULONG ulBdaParameter);
- NTSTATUS SetTransponder(IN ULONG ulBdaParameter);
- NTSTATUS SetLowLOFrequency(IN ULONG ulBdaParameter);
- NTSTATUS SetHighLOFrequency(IN ULONG ulBdaParameter);
- NTSTATUS SetSwitchFrequency(IN ULONG ulBdaParameter);
-
- //Demodulator Node Properties
- NTSTATUS GetDemodProperty(OUT PBDATUNER_DEVICE_PARAMETER pDemodParameter);
- NTSTATUS SetModulatorType(IN ModulationType NewModulatorType);
- NTSTATUS SetInnerFecType(IN ULONG ulNewInnerFecType);
- NTSTATUS SetInnerFecRate(IN BinaryConvolutionCodeRate NewFecRate);
- NTSTATUS SetOuterFecType(IN ULONG ulNewOuterFecType);
- NTSTATUS SetOuterFecRate(IN BinaryConvolutionCodeRate NewFecRate);
- NTSTATUS SetSymbolRate(IN ULONG ulNewSymbolRate);
- NTSTATUS SetSpectralInversion(IN SpectralInversion SpecInv);
- NTSTATUS SetGuardInterval(IN GuardInterval GuardInt);
- NTSTATUS SetTransmissionMode(IN TransmissionMode TransMode);
-
- //Extended Property
- NTSTATUS SendDiseqcCommand(IN PDISEQC_COMMAND pDiseqcCommand);
-
- //Function to retrive the Device Status.
- NTSTATUS GetStatus(PBDATUNER_DEVICE_STATUS pDeviceStatus);
-
- //Functions to get and release device access
- NTSTATUS AcquireResources();
- NTSTATUS ReleaseResources();
-
-
-private:
- class CSkyWalker1Device * m_pDevice;
-
- //Filter Resources
- KSSTATE m_KsState;
- BDA_CHANGE_STATE m_BdaChangeState;
- BDATUNER_DEVICE_PARAMETER m_CurResource;
- BDATUNER_DEVICE_PARAMETER m_NewResource;
- ULONG m_ulResourceID;
- BOOLEAN m_fResourceAcquired;
- CTunerFilter();
- ~CTunerFilter();
-};
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1TunerFilter.h
+ Author :
+ Date :
+ Purpose : Tuner Filter Class Definition
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef SKYWALKER1_TUNER_FILTER_H
+#define SKYWALKER1_TUNER_FILTER_H
+
+/* Include the Library and Other header file */
+#include "SkyWalker1CommonDef.h"
+#include "SkyWalker1Device.h"
+#include "SkyWalker1Extended.h"
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+//The Tuner Filter class.
+class CTunerFilter
+{
+public:
+
+ //Functions to Create and Close Filter
+ static NTSTATUS Create( IN OUT PKSFILTER pKSFilter,
+ IN PIRP pIoRequestPacket);
+
+ static NTSTATUS FilterClose( IN OUT PKSFILTER pKSFilter,
+ IN PIRP pIoRequestPacket);
+
+ //KSMETHODSETID_BdaChangeSync pKSFilter change sync methods
+ static NTSTATUS StartChanges( IN PIRP pIoRequestPacket,
+ IN PKSMETHOD pKSMethod,
+ OPTIONAL PVOID pvIgnored);
+
+ static NTSTATUS CheckChanges( IN PIRP pIoRequestPacket,
+ IN PKSMETHOD pKSMethod,
+ OPTIONAL PVOID pvIgnored);
+
+ static NTSTATUS CommitChanges( IN PIRP pIoRequestPacket,
+ IN PKSMETHOD pKSMethod,
+ OPTIONAL PVOID pvIgnored);
+
+ static NTSTATUS GetChangeState( IN PIRP pIoRequestPacket,
+ IN PKSMETHOD pKSMethod,
+ OUT PULONG pulChangeState);
+
+
+ //KSMETHODSETID_BdaDeviceConfiguration Method to modify filter topology.
+ static NTSTATUS CreateTopology( IN PIRP pIoRequestPacket,
+ IN PKSMETHOD pKSMethod,
+ OPTIONAL PVOID pvIgnored);
+
+
+ //pKSFilter Implementation Methods
+ (class CSkyWalker1Device *) GetDevice()
+ {
+ return m_pDevice;
+ };
+
+ NTSTATUS SetDeviceState(KSSTATE NewKsState)
+ {
+ m_KsState = NewKsState;
+ return STATUS_SUCCESS;
+ };
+
+
+ //Tuner Node Properties
+ NTSTATUS GetTunerProperty(OUT PBDATUNER_DEVICE_PARAMETER pTunerParameter);
+ NTSTATUS SetFrequency(IN ULONG ulBdaParameter);
+ NTSTATUS SetMultiplier(IN ULONG ulBdaParameter);
+ NTSTATUS SetBandwidth(IN ULONG ulBdaParameter);
+ NTSTATUS SetPolarity(IN Polarisation NewPolarity);
+ NTSTATUS SetRange(IN ULONG ulBdaParameter);
+ NTSTATUS SetTransponder(IN ULONG ulBdaParameter);
+ NTSTATUS SetLowLOFrequency(IN ULONG ulBdaParameter);
+ NTSTATUS SetHighLOFrequency(IN ULONG ulBdaParameter);
+ NTSTATUS SetSwitchFrequency(IN ULONG ulBdaParameter);
+
+ //Demodulator Node Properties
+ NTSTATUS GetDemodProperty(OUT PBDATUNER_DEVICE_PARAMETER pDemodParameter);
+ NTSTATUS SetModulatorType(IN ModulationType NewModulatorType);
+ NTSTATUS SetInnerFecType(IN ULONG ulNewInnerFecType);
+ NTSTATUS SetInnerFecRate(IN BinaryConvolutionCodeRate NewFecRate);
+ NTSTATUS SetOuterFecType(IN ULONG ulNewOuterFecType);
+ NTSTATUS SetOuterFecRate(IN BinaryConvolutionCodeRate NewFecRate);
+ NTSTATUS SetSymbolRate(IN ULONG ulNewSymbolRate);
+ NTSTATUS SetSpectralInversion(IN SpectralInversion SpecInv);
+ NTSTATUS SetGuardInterval(IN GuardInterval GuardInt);
+ NTSTATUS SetTransmissionMode(IN TransmissionMode TransMode);
+
+ //Extended Property
+ NTSTATUS SendDiseqcCommand(IN PDISEQC_COMMAND pDiseqcCommand);
+
+ //Function to retrive the Device Status.
+ NTSTATUS GetStatus(PBDATUNER_DEVICE_STATUS pDeviceStatus);
+
+ //Functions to get and release device access
+ NTSTATUS AcquireResources();
+ NTSTATUS ReleaseResources();
+
+
+private:
+ class CSkyWalker1Device * m_pDevice;
+
+ //Filter Resources
+ KSSTATE m_KsState;
+ BDA_CHANGE_STATE m_BdaChangeState;
+ BDATUNER_DEVICE_PARAMETER m_CurResource;
+ BDATUNER_DEVICE_PARAMETER m_NewResource;
+ ULONG m_ulResourceID;
+ BOOLEAN m_fResourceAcquired;
+ CTunerFilter();
+ ~CTunerFilter();
+};
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*SKYWALKER1_TUNER_FILTER_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerPin.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerPin.h
index b815d67..1f19b3d 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerPin.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1TunerPin.h
@@ -1,82 +1,82 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1TunerPin.h
- Author :
- Date :
- Purpose : This File Holds the Generic Tuner Pin related declarations
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_TUNER_PIN_H
-#define __SKYWALKER1_TUNER_PIN_H
-
-/* Include the Library and Other header file */
-#include "SkyWalker1CommonDef.h"
-#include "SkyWalker1TunerFilter.h"
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-
-// The Tuner Pin class.
-class CTunerPin
-{
-public:
-
-
- //Creates the Pin
- static NTSTATUS PinCreate( IN OUT PKSPIN pKSPin,
- IN PIRP pIoRequestPacket
- );
-
- //Closes the Opened Pin
- static NTSTATUS PinClose( IN OUT PKSPIN pKSPin,
- IN PIRP pIoRequestPacket
- );
-
- //Member Function to get the Various Signal attributes
- static NTSTATUS GetSignalStatus(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- );
-
-
- (class CTunerFilter *) GetFilter(void)
- {
- return m_pFilter;
- };
-
- void SetFilter(class CTunerFilter * pFilter)
- {
- m_pFilter = pFilter;
- };
-
-protected:
-
- class CTunerFilter* m_pFilter;
-
-};
-
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1TunerPin.h
+ Author :
+ Date :
+ Purpose : This File Holds the Generic Tuner Pin related declarations
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_TUNER_PIN_H
+#define __SKYWALKER1_TUNER_PIN_H
+
+/* Include the Library and Other header file */
+#include "SkyWalker1CommonDef.h"
+#include "SkyWalker1TunerFilter.h"
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+
+// The Tuner Pin class.
+class CTunerPin
+{
+public:
+
+
+ //Creates the Pin
+ static NTSTATUS PinCreate( IN OUT PKSPIN pKSPin,
+ IN PIRP pIoRequestPacket
+ );
+
+ //Closes the Opened Pin
+ static NTSTATUS PinClose( IN OUT PKSPIN pKSPin,
+ IN PIRP pIoRequestPacket
+ );
+
+ //Member Function to get the Various Signal attributes
+ static NTSTATUS GetSignalStatus(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ );
+
+
+ (class CTunerFilter *) GetFilter(void)
+ {
+ return m_pFilter;
+ };
+
+ void SetFilter(class CTunerFilter * pFilter)
+ {
+ m_pFilter = pFilter;
+ };
+
+protected:
+
+ class CTunerFilter* m_pFilter;
+
+};
+
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_TUNER_PIN_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1USB.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1USB.h
index 1f41a30..1dd2ea8 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1USB.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1USB.h
@@ -1,126 +1,126 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Usb.h
- Author :
- Date :
- Purpose : This File Holds all the USB Device access related declarations
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-
-#ifndef __SKYWALKER1_USB_H
-#define __SKYWALKER1_USB_H
-
-/* Include the Library and Other header file */
-extern "C"
-{
-//USB Related Headers
-#include
-#pragma warning(disable:4200)
-#include
-#include
-#include
-#include
-#include "SkyWalker1Device.h"
-
-}
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-#define MAX_BULK_PACKET_SIZE 8 * 512
-#define MAX_BULK_TRANSFER_SIZE (TRANSPORT_PACKET_COUNT * TRANSPORT_PACKET_SIZE) //Suppoting max Frame Size
-/* End of Macro Definitions */
-
-/* Declare Enumerations here */
-typedef enum __USBSTATE {
-
- NotStarted, // not started
- Stopped, // device stopped
- Working, // started and working
- PendingStop, // stop pending
- PendingRemove, // remove pending
- SurpriseRemoved, // removed by surprise
- Removed // removed
-
-}USBSTATE;
-
-typedef enum _QUEUE_STATE {
-
- HoldRequests, // device is not started yet
- AllowRequests, // device is ready to process
- FailRequests // fail both existing and queued up requests
-
-} QUEUE_STATE;
-
-#define INITIALIZE_PNP_STATE(_Data_) \
- (_Data_)->UsbDeviceState = NotStarted;\
- (_Data_)->PreviousUsbDeviceState = NotStarted;
-
-#define SET_NEW_PNP_STATE(_Data_, _state_) \
- (_Data_)->PreviousUsbDeviceState = (_Data_)->UsbDeviceState;\
- (_Data_)->UsbDeviceState = (_state_);
-
-#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \
- (_Data_)->UsbDeviceState = (_Data_)->PreviousUsbDeviceState;
-
-/* End of Enumeration declaration */
-
-/* Global & Static variables Declaration */
-//BulkUsb Read Write Context
-typedef struct _BULKUSB_RW_CONTEXT {
-
- PURB pUSBRequestBlock;
- PUCHAR pTransferBuffer;
- ULONG ulRemainingByteTransfer; // remaining to xfer
- ULONG ulCompletedByteTransfer; // cumulate xfer
- ULONG ulStreamIndex;
- class CSkyWalker1Device * pDevice;
-
-} BULKUSB_RW_CONTEXT, * PBULKUSB_RW_CONTEXT;
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Function Prototypes */
-//Usb Access functions
-NTSTATUS InitializeUsbDevice(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoReqestPacket);
-NTSTATUS DeconfigureUsbDevice(IN PKSDEVICE pKSDeviceObject);
-NTSTATUS StopUsbDevice(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS ReadWriteUsbDevice(IN PKSDEVICE pKSDeviceObject,
- IN ULONG ulStreamIndex,
- IN ULONG ulPacketIndex,
- IN PUCHAR pucTransferBuffer,
- IN ULONG ulTransferLength,
- IN BOOLEAN bRead);
-NTSTATUS ControlUsbDevice( IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucRequest,
- IN USHORT usValue,
- IN USHORT usIndex,
- IN PUCHAR pucTransferBuffer,
- IN ULONG ulTransferLength,
- IN BOOLEAN bRead);
-NTSTATUS RemoveUsbDevice( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS SurpriseUsbDeviceRemoval(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS CancelRemoveUsbDevice(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS QueryRemoveUsbDevice( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS QueryStopUsbDevice(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-NTSTATUS CancelStopUsbDevice(IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket);
-
-/* End of Function prototype definitions */
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1Usb.h
+ Author :
+ Date :
+ Purpose : This File Holds all the USB Device access related declarations
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+
+#ifndef __SKYWALKER1_USB_H
+#define __SKYWALKER1_USB_H
+
+/* Include the Library and Other header file */
+extern "C"
+{
+//USB Related Headers
+#include
+#pragma warning(disable:4200)
+#include
+#include
+#include
+#include
+#include "SkyWalker1Device.h"
+
+}
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+#define MAX_BULK_PACKET_SIZE 8 * 512
+#define MAX_BULK_TRANSFER_SIZE (TRANSPORT_PACKET_COUNT * TRANSPORT_PACKET_SIZE) //Suppoting max Frame Size
+/* End of Macro Definitions */
+
+/* Declare Enumerations here */
+typedef enum __USBSTATE {
+
+ NotStarted, // not started
+ Stopped, // device stopped
+ Working, // started and working
+ PendingStop, // stop pending
+ PendingRemove, // remove pending
+ SurpriseRemoved, // removed by surprise
+ Removed // removed
+
+}USBSTATE;
+
+typedef enum _QUEUE_STATE {
+
+ HoldRequests, // device is not started yet
+ AllowRequests, // device is ready to process
+ FailRequests // fail both existing and queued up requests
+
+} QUEUE_STATE;
+
+#define INITIALIZE_PNP_STATE(_Data_) \
+ (_Data_)->UsbDeviceState = NotStarted;\
+ (_Data_)->PreviousUsbDeviceState = NotStarted;
+
+#define SET_NEW_PNP_STATE(_Data_, _state_) \
+ (_Data_)->PreviousUsbDeviceState = (_Data_)->UsbDeviceState;\
+ (_Data_)->UsbDeviceState = (_state_);
+
+#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \
+ (_Data_)->UsbDeviceState = (_Data_)->PreviousUsbDeviceState;
+
+/* End of Enumeration declaration */
+
+/* Global & Static variables Declaration */
+//BulkUsb Read Write Context
+typedef struct _BULKUSB_RW_CONTEXT {
+
+ PURB pUSBRequestBlock;
+ PUCHAR pTransferBuffer;
+ ULONG ulRemainingByteTransfer; // remaining to xfer
+ ULONG ulCompletedByteTransfer; // cumulate xfer
+ ULONG ulStreamIndex;
+ class CSkyWalker1Device * pDevice;
+
+} BULKUSB_RW_CONTEXT, * PBULKUSB_RW_CONTEXT;
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Function Prototypes */
+//Usb Access functions
+NTSTATUS InitializeUsbDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoReqestPacket);
+NTSTATUS DeconfigureUsbDevice(IN PKSDEVICE pKSDeviceObject);
+NTSTATUS StopUsbDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS ReadWriteUsbDevice(IN PKSDEVICE pKSDeviceObject,
+ IN ULONG ulStreamIndex,
+ IN ULONG ulPacketIndex,
+ IN PUCHAR pucTransferBuffer,
+ IN ULONG ulTransferLength,
+ IN BOOLEAN bRead);
+NTSTATUS ControlUsbDevice( IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucRequest,
+ IN USHORT usValue,
+ IN USHORT usIndex,
+ IN PUCHAR pucTransferBuffer,
+ IN ULONG ulTransferLength,
+ IN BOOLEAN bRead);
+NTSTATUS RemoveUsbDevice( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS SurpriseUsbDeviceRemoval(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS CancelRemoveUsbDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS QueryRemoveUsbDevice( IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS QueryStopUsbDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+NTSTATUS CancelStopUsbDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PIRP pIoRequestPacket);
+
+/* End of Function prototype definitions */
+
#endif /*__SKYWALKER1_USB_H*/
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Utility.h b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Utility.h
index f018fbc..28befbf 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Utility.h
+++ b/firmware-driver/SkyWalker1_Final_Release/Include/SkyWalker1Utility.h
@@ -1,91 +1,91 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Utility.h
- Author :
- Date :
- Purpose : This file basically holds the Utility related Common Declarations
- used in the SkyWalker Driver Module
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-#ifndef SKYWALKER1_UTILITY_H
-#define SKYWALKER1_UTILITY_H
-
-/* Include the Library and Other header file */
-#include
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-#define SKYWALKER1_DRIVER_NAME "SkyWalker1TVTuner"
-
-extern int nCurrentDebugLevel;
-
-#define DEBUG_ON
-#ifdef DEBUG_ON
-
-#define SkyWalkerDebugPrint(DebugLevel,_ARGUMENTS_) \
- if((DebugLevel) <= nCurrentDebugLevel) \
- { \
- DbgPrint _ARGUMENTS_; \
- }
-
-#else
-
-#define SkyWalkerDebugPrint(DebugLevel,__ARGUMENTS__)
-
-#endif
-
-#define TRUE 1
-#define FALSE 0
-
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-
-/* ENUM : enDebugLevels */
-/* PURPOSE : To Define Different Debug Levels */
-enum enDebugLevels
-{
- DISABLE_DEBUG = 0,
- ENTRY_LEVEL,
- INTERMEDIATE_LEVEL,
- EXTREME_LEVEL,
-};
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-void PrintFunctionEntry(IN char * pcFunctionName);
-void PrintFunctionExit(IN char * pcFunctionName, IN NTSTATUS ntReturnCode);
-char * GetCurrentIrqlString(void);
-VOID Delay(IN ULONG ulDelayInMicroSeconds); //To Delay the Execution Thread
-
-NTSTATUS LowerDeviceCompletedIrp(IN PDEVICE_OBJECT pDeviceObject,
- IN PIRP pIoRequestPacket,
- IN PVOID pContext);
-NTSTATUS PassDownIRPAndWaitForCompletion(IN PDEVICE_OBJECT pLowerDeviceObject,
- IN PIRP pIoRequestPacket,
- IN BOOLEAN bCopyStackLocation);
-NTSTATUS PassDownIRPAndForget(IN PDEVICE_OBJECT pLowerDeviceObject,
- IN PIRP pIoRequestPacket);
-VOID CompleteIrpInDispatch(IN PDEVICE_OBJECT pDeviceObject,
- IN PIRP pIoRequestPacket);
-PUCHAR NTStatusToString(NTSTATUS Status) ;
-VOID PrintDeviceChangeState(IN KSSTATE ToState,IN KSSTATE FromState);
-/* End of Function prototype definitions */
-
-
-
-#endif /*SKYWALKER1_UTILITY_H*/
-
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1Utility.h
+ Author :
+ Date :
+ Purpose : This file basically holds the Utility related Common Declarations
+ used in the SkyWalker Driver Module
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+#ifndef SKYWALKER1_UTILITY_H
+#define SKYWALKER1_UTILITY_H
+
+/* Include the Library and Other header file */
+#include
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+#define SKYWALKER1_DRIVER_NAME "SkyWalker1TVTuner"
+
+extern int nCurrentDebugLevel;
+
+#define DEBUG_ON
+#ifdef DEBUG_ON
+
+#define SkyWalkerDebugPrint(DebugLevel,_ARGUMENTS_) \
+ if((DebugLevel) <= nCurrentDebugLevel) \
+ { \
+ DbgPrint _ARGUMENTS_; \
+ }
+
+#else
+
+#define SkyWalkerDebugPrint(DebugLevel,__ARGUMENTS__)
+
+#endif
+
+#define TRUE 1
+#define FALSE 0
+
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+
+/* ENUM : enDebugLevels */
+/* PURPOSE : To Define Different Debug Levels */
+enum enDebugLevels
+{
+ DISABLE_DEBUG = 0,
+ ENTRY_LEVEL,
+ INTERMEDIATE_LEVEL,
+ EXTREME_LEVEL,
+};
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+void PrintFunctionEntry(IN char * pcFunctionName);
+void PrintFunctionExit(IN char * pcFunctionName, IN NTSTATUS ntReturnCode);
+char * GetCurrentIrqlString(void);
+VOID Delay(IN ULONG ulDelayInMicroSeconds); //To Delay the Execution Thread
+
+NTSTATUS LowerDeviceCompletedIrp(IN PDEVICE_OBJECT pDeviceObject,
+ IN PIRP pIoRequestPacket,
+ IN PVOID pContext);
+NTSTATUS PassDownIRPAndWaitForCompletion(IN PDEVICE_OBJECT pLowerDeviceObject,
+ IN PIRP pIoRequestPacket,
+ IN BOOLEAN bCopyStackLocation);
+NTSTATUS PassDownIRPAndForget(IN PDEVICE_OBJECT pLowerDeviceObject,
+ IN PIRP pIoRequestPacket);
+VOID CompleteIrpInDispatch(IN PDEVICE_OBJECT pDeviceObject,
+ IN PIRP pIoRequestPacket);
+PUCHAR NTStatusToString(NTSTATUS Status) ;
+VOID PrintDeviceChangeState(IN KSSTATE ToState,IN KSSTATE FromState);
+/* End of Function prototype definitions */
+
+
+
+#endif /*SKYWALKER1_UTILITY_H*/
+
diff --git a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1AntennaPin.cpp b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1AntennaPin.cpp
index 589edca..c3ec4f2 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1AntennaPin.cpp
+++ b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1AntennaPin.cpp
@@ -1,546 +1,546 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1AntennaPin.cpp
- Author :
- Date :
- Purpose : This File Holds the Antenna Pin related declarations
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-/* Include the Library and Other header file */
-
-#include "SkyWalker1Main.h" //Common For all the Definitions,
- //Declarations and Library Routines
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-PCHAR GetTunerPropertyString(ULONG ulTunerProperty);
-PCHAR GetTunerLnbPropertyString(ULONG ulTunerLnbProperty);
-/* End of Function prototype definitions */
-
-/*****************************************************************************
- Function : CAntennaPin::IntersectDataFormat
- Description : Enables connection of the input pin with a upstream filter.
- IN PARAM :
- OUT PARAM : Status of the IntersectDataFormat
- PreCondition : None
- PostCondtion : None
- Logic : NONE
- Assumption : NONE
- Note : This is called from the PASSIVE_LEVEL_IRQL
- Revision History:
- *****************************************************************************/
-NTSTATUS CAntennaPin::IntersectDataFormat(
- IN PVOID pContext,
- IN PIRP pIoRequestPacket,
- IN PKSP_PIN Pin,
- IN PKSDATARANGE pDataRange,
- IN PKSDATARANGE pMatchingDataRange,
- IN ULONG ulDataBufferSize,
- OUT PVOID pData OPTIONAL,
- OUT PULONG pulDataSize
- )
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
-
- PrintFunctionEntry(__FUNCTION__);
-
- if ( ulDataBufferSize < sizeof(KS_DATARANGE_BDA_ANTENNA) )
- {
- *pulDataSize = sizeof( KS_DATARANGE_BDA_ANTENNA );
- ntStatus = STATUS_BUFFER_OVERFLOW;
- goto ExitDataFormat;
- }
- else if (pDataRange->FormatSize < sizeof (KS_DATARANGE_BDA_ANTENNA))
- {
- ntStatus = STATUS_NO_MATCH;
- goto ExitDataFormat;
- }
- else
- {
- *pulDataSize = sizeof( KS_DATARANGE_BDA_ANTENNA );
- RtlCopyMemory( pData, (PVOID)pDataRange, sizeof(KS_DATARANGE_BDA_ANTENNA));
- ntStatus = STATUS_SUCCESS;
- }
-
-ExitDataFormat:
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-
-}
-
-/*****************************************************************************
- Function : CAntennaPin::PinSetDeviceState
- Description : An AVStream minidriver's AVStrMiniPinSetDeviceState
- routine is called when the state of a KSPIN structure is
- changed due to the arrival of a connection state property
- 'set' IOCTL. Typically, this will be provided by minidrivers
- that need to change the state of hardware.
-
- The KSSTATE enumeration lists possible states of a kernel
- streaming object.
- typedef enum {
- KSSTATE_STOP;
- KSSTATE_ACQUIRE;
- KSSTATE_PAUSE;
- KSSTATE_RUN;
- } KSSTATE;
-
- Enumerators
- KSSTATE_STOP
- Indicates that the object is in minimum resource consumption mode.
- KSSTATE_ACQUIRE
- Indicates that the object is acquiring resources.
- KSSTATE_PAUSE
- Indicates that the object is preparing to make instant transition to Run state.
- KSSTATE_RUN
- Indicates that the object is actively streaming.
-
- Because the most upstream pin (input pin) is the last
- to transition, use this pin's state to set the state
- of the filter.
- Also, release filter resouces if the pin's state
- transitions to stop, and acquire resources if the pin's
- state transitions from stop.
- IN PARAM : Pointer to the KSPIN structure for which state is changing.
- The target KSSTATE after receipt of the IOCTL.
- The previous KSSTATE.
- OUT PARAM : Status of the PinSetDeviceState
- PreCondition : None
- PostCondtion : None
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CAntennaPin::PinSetDeviceState(
- IN PKSPIN pKSPin,
- IN KSSTATE ToState,
- IN KSSTATE FromState
- )
-{
- NTSTATUS ntSetStatus = STATUS_SUCCESS;
- PKSDEVICE pKSDevice = NULL;
- CAntennaPin * pPin = NULL;
- CSkyWalker1Device * pDevice = NULL;
-
- PrintFunctionEntry(__FUNCTION__);
-
- //Obtain a pointer to the device object from
- //the passed in pointer to the KSPIN structure.
- pKSDevice = KsPinGetDevice( pKSPin);
-
- //Obtain a pointer to the pin object from context member of
- //the passed in pointer to the KSPIN structure.
- pPin = reinterpret_cast(pKSPin->Context);
-
- //Obtain a pointer to the device object from context member of
- //the retrieved pointer to the KSDEVICE structure.
- pDevice = reinterpret_cast(pKSDevice->Context);
-
- pPin->m_pFilter->SetDeviceState( pPin->m_KsState);
-
- if ((ToState == KSSTATE_STOP) && (FromState != KSSTATE_STOP))
- {
- //Because the driver allocates resources on a filter wide basis,
- //inform the filter to release resources when the last pin
- //(that is, the most upstream pin) transitions to the stop state.
- //
- //The input pin is the last pin to transition to the stop state,
- //therefore inform the filter to release its resources.
- //
- ntSetStatus = pPin->m_pFilter->ReleaseResources();
- pPin->m_KsState = ToState;
- }
- else if ((ToState == KSSTATE_ACQUIRE) && (FromState == KSSTATE_STOP))
- {
- //Because the driver allocates resources on a filter wide basis,
- //inform the filter to acquire resources when the last pin
- //(that is, the most upstream pin) transitions from the stop state.
- //
- //The input pin is the last pin to transition from the stop state,
- //therefore inform the filter to acquire its resources.
- //
- ntSetStatus = pPin->m_pFilter->AcquireResources();
- if (NT_SUCCESS( ntSetStatus))
- {
- pPin->m_KsState = ToState;
- }
- }
- else if (ToState > KSSTATE_RUN)
- {
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,
- ("Invalid Device State. ToState 0x%08x. FromState 0x%08x.",
- ToState, FromState));
- ntSetStatus = STATUS_INVALID_PARAMETER;
- }
- else
- {
- pPin->m_KsState = ToState;
- }
-
- PrintDeviceChangeState(ToState,FromState);
-
- PrintFunctionExit(__FUNCTION__,ntSetStatus);
- return ntSetStatus;
-}
-
-
-
-/*****************************************************************************
- Function : CAntennaPin::GetTunerProperty
- Description : Retrieves the value of the Tuner node Properties
- IN PARAM : IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- OUT PULONG pulProperty
- OUT PARAM : Status SUCCESS in case Valid Property request
- STATUS_INVALID_PARAMETER in case of Invalid property request
- Else error from the lower device
- PreCondition : None
- PostCondtion : Tuner propery read in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CAntennaPin::GetTunerProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- OUT PULONG pulProperty
- )
-{
- NTSTATUS ntGetStatus = STATUS_SUCCESS;
- CAntennaPin * pPin = NULL;
- CTunerFilter* pFilter = NULL;
- BDATUNER_DEVICE_PARAMETER TunerProperty;
-
- PrintFunctionEntry(__FUNCTION__);
- //Call the BDA support library to
- //validate that the node type is associated with the pin.
-
- //The BdaValidateNodeProperty function validates that a node property
- //request is associated with a specific pin.
- ntGetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
- if (NT_SUCCESS( ntGetStatus))
- {
- //Obtain a pointer to the pin object.
-
- //Because the property dispatch table calls the CAntennaPin::GetTunerProperty()
- //method directly, the method must retrieve a pointer to the underlying pin object.
- pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
-
- //Retrieve the filter context from the pin context.
- pFilter = pPin->GetFilter();
-
- ntGetStatus = pFilter->GetTunerProperty(&TunerProperty);
- //Retrieve the actual filter parameter.
- switch (pKSProperty->Id)
- {
- case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
- *pulProperty = TunerProperty.ulCarrierFrequency;
- break;
- case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
- *pulProperty = TunerProperty.ulFrequencyMultiplier;
- break;
- case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
- *pulProperty = TunerProperty.ulBandWidth;
- break;
- case KSPROPERTY_BDA_RF_TUNER_POLARITY:
- *pulProperty = TunerProperty.Polarity;
- break;
- case KSPROPERTY_BDA_RF_TUNER_RANGE:
- *pulProperty = TunerProperty.ulRange;
- break;
- case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
- *pulProperty = TunerProperty.ulTransponder;
- break;
- default:
- ntGetStatus = STATUS_INVALID_PARAMETER;
- break;
- }
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Get : %s : %ul",GetTunerPropertyString(pKSProperty->Id),*pulProperty));
-
- PrintFunctionExit(__FUNCTION__,ntGetStatus);
- return ntGetStatus;
-}
-
-/*****************************************************************************
- Function : CAntennaPin::SetTunerProperty
- Description : Sets the value of the Tuner node Freq. Properties
- IN PARAM : IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- OUT PULONG pulProperty
- OUT PARAM : Status SUCCESS in case Valid Property request
- STATUS_INVALID_PARAMETER in case of Invalid property request
- Else error from the lower device
- PreCondition : None
- PostCondtion : Tuner Freq. property read in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CAntennaPin::SetTunerProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- )
-{
- NTSTATUS ntSetStatus = STATUS_SUCCESS;
- CAntennaPin * pPin;
- CTunerFilter* pFilter;
-
- PrintFunctionEntry(__FUNCTION__);
- //Call the BDA support library to
- //validate that the node type is associated with the pin.
-
- //The BdaValidateNodeProperty function validates that a node property
- //request is associated with a specific pin.
- ntSetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
- if (NT_SUCCESS( ntSetStatus))
- {
- //Obtain a pointer to the pin object.
-
- //Because the property dispatch table calls the CAntennaPin::SetTunerProperty()
- //method directly, the method must retrieve a pointer to the underlying pin object.
- pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
-
- //Retrieve the filter context from the pin context.
- pFilter = pPin->GetFilter();
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Set : %s : %lu\n",
- GetTunerPropertyString(pKSProperty->Id),
- *pulProperty));
- //Retrieve the actual filter parameter.
- switch (pKSProperty->Id)
- {
- case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
- ntSetStatus = pFilter->SetFrequency(*pulProperty);
- break;
- case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
- ntSetStatus = pFilter->SetMultiplier(*pulProperty);
- break;
- case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
- ntSetStatus = pFilter->SetBandwidth(*pulProperty);
- break;
- case KSPROPERTY_BDA_RF_TUNER_POLARITY:
- ntSetStatus = pFilter->SetPolarity((Polarisation) *pulProperty);
- break;
- case KSPROPERTY_BDA_RF_TUNER_RANGE:
- ntSetStatus = pFilter->SetRange(*pulProperty);
- break;
- case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
- ntSetStatus = pFilter->SetTransponder(*pulProperty);
- break;
- default:
- ntSetStatus = STATUS_INVALID_PARAMETER;
- break;
- }
- }
-
- PrintFunctionExit(__FUNCTION__,ntSetStatus);
- return ntSetStatus;
-}
-
-/*****************************************************************************
- Function : CAntennaPin::GetTunerLnbProperty
- Description : Retrieves the value of the Tuner Lnb node Properties
- IN PARAM : IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- OUT PULONG pulProperty
- OUT PARAM : Status SUCCESS in case Valid Property request
- STATUS_INVALID_PARAMETER in case of Invalid property request
- Else error from the lower device
- PreCondition : None
- PostCondtion : Tuner lnb propery read in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CAntennaPin::GetTunerLnbProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- OUT PULONG pulProperty
- )
-{
- NTSTATUS ntGetStatus = STATUS_SUCCESS;
- CAntennaPin * pPin;
- CTunerFilter* pFilter;
- BDATUNER_DEVICE_PARAMETER LnbProperty;
-
- PrintFunctionEntry(__FUNCTION__);
- //Call the BDA support library to
- //validate that the node type is associated with the pin.
-
- //The BdaValidateNodeProperty function validates that a node property
- //request is associated with a specific pin.
- ntGetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
- if (NT_SUCCESS( ntGetStatus))
- {
- //Obtain a pointer to the pin object.
-
- //Because the property dispatch table calls the CAntennaPin::GetTunerProperty()
- //method directly, the method must retrieve a pointer to the underlying pin object.
- pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
-
- //Retrieve the filter context from the pin context.
- pFilter = pPin->GetFilter();
-
- ntGetStatus = pFilter->GetTunerProperty(&LnbProperty);
-
- //Retrieve the actual filter parameter.
- switch (pKSProperty->Id)
- {
- case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
- *pulProperty = LnbProperty.ulLnbLowLOFrequency;
- break;
- case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
- *pulProperty = LnbProperty.ulLnbHighLOFrequency;
- break;
- case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
- *pulProperty = LnbProperty.ulLnbSwitchFrequency;
- break;
- default:
- ntGetStatus = STATUS_INVALID_PARAMETER;
- break;
- }
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Get : %s : %ul",GetTunerLnbPropertyString(pKSProperty->Id),*pulProperty));
-
- PrintFunctionExit(__FUNCTION__,ntGetStatus);
- return ntGetStatus;
-}
-
-/*****************************************************************************
- Function : CAntennaPin::SetTunerLnbProperty
- Description : Sets the value of the Tuner Lnb node Properties
- IN PARAM : IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- OUT PARAM : Status SUCCESS in case Valid Property request
- STATUS_INVALID_PARAMETER in case of Invalid property request
- Else error from the lower device
- PreCondition : None
- PostCondtion : Tuner propery Set in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CAntennaPin::SetTunerLnbProperty(
- IN PIRP pIoRequestPacket,
- IN PKSPROPERTY pKSProperty,
- IN PULONG pulProperty
- )
-{
- NTSTATUS ntSetStatus = STATUS_SUCCESS;
- CAntennaPin * pPin;
- CTunerFilter* pFilter;
-
- PrintFunctionEntry(__FUNCTION__);
- //Call the BDA support library to
- //validate that the node type is associated with the pin.
-
- //The BdaValidateNodeProperty function validates that a node property
- //request is associated with a specific pin.
- ntSetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
- if (NT_SUCCESS( ntSetStatus))
- {
- //Obtain a pointer to the pin object.
-
- //Because the property dispatch table calls the CAntennaPin::SetTunerProperty()
- //method directly, the method must retrieve a pointer to the underlying pin object.
-
- pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
-
- //Retrieve the filter context from the pin context.
- pFilter = pPin->GetFilter();
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Set : %s : %lu(%l)",
- GetTunerLnbPropertyString(pKSProperty->Id),
- *pulProperty,
- *((LONG*)(pulProperty))));
- //Retrieve the actual filter parameter.
- switch (pKSProperty->Id)
- {
- case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
- ntSetStatus = pFilter->SetLowLOFrequency(*pulProperty);
- break;
- case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
- ntSetStatus = pFilter->SetHighLOFrequency(*pulProperty);
- break;
- case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
- ntSetStatus = pFilter->SetSwitchFrequency(*pulProperty);
- break;
- default:
- ntSetStatus = STATUS_INVALID_PARAMETER;
- break;
- }
- }
-
- PrintFunctionExit(__FUNCTION__,ntSetStatus);
- return ntSetStatus;
-}
-
-
-
-
-PCHAR GetTunerPropertyString(ULONG ulTunerProperty)
-{
- switch(ulTunerProperty)
- {
- case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
- return "KSPROPERTY_BDA_RF_TUNER_FREQUENCY";
- case KSPROPERTY_BDA_RF_TUNER_POLARITY:
- return "KSPROPERTY_BDA_RF_TUNER_POLARITY";
- case KSPROPERTY_BDA_RF_TUNER_RANGE:
- return "KSPROPERTY_BDA_RF_TUNER_RANGE";
- case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
- return "KSPROPERTY_BDA_RF_TUNER_TRANSPONDER";
- case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
- return "KSPROPERTY_BDA_RF_TUNER_BANDWIDTH";
- case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
- return "KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER";
- default:
- return "KSPROPERTY_BDA_INVALID_PROPERTY";
- }
-}
-
-PCHAR GetTunerLnbPropertyString(ULONG ulTunerLnbProperty)
-{
- switch(ulTunerLnbProperty)
- {
- case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
- return "KSPROPERTY_BDA_LNB_LOF_LOW_BAND";
- case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
- return "KSPROPERTY_BDA_LNB_LOF_HIGH_BAND";
- case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
- return "KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY";
- default:
- return "KSPROPERTY_BDA_INVALID_PROPERTY";
- }
-}
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1AntennaPin.cpp
+ Author :
+ Date :
+ Purpose : This File Holds the Antenna Pin related declarations
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+/* Include the Library and Other header file */
+
+#include "SkyWalker1Main.h" //Common For all the Definitions,
+ //Declarations and Library Routines
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+PCHAR GetTunerPropertyString(ULONG ulTunerProperty);
+PCHAR GetTunerLnbPropertyString(ULONG ulTunerLnbProperty);
+/* End of Function prototype definitions */
+
+/*****************************************************************************
+ Function : CAntennaPin::IntersectDataFormat
+ Description : Enables connection of the input pin with a upstream filter.
+ IN PARAM :
+ OUT PARAM : Status of the IntersectDataFormat
+ PreCondition : None
+ PostCondtion : None
+ Logic : NONE
+ Assumption : NONE
+ Note : This is called from the PASSIVE_LEVEL_IRQL
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CAntennaPin::IntersectDataFormat(
+ IN PVOID pContext,
+ IN PIRP pIoRequestPacket,
+ IN PKSP_PIN Pin,
+ IN PKSDATARANGE pDataRange,
+ IN PKSDATARANGE pMatchingDataRange,
+ IN ULONG ulDataBufferSize,
+ OUT PVOID pData OPTIONAL,
+ OUT PULONG pulDataSize
+ )
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ if ( ulDataBufferSize < sizeof(KS_DATARANGE_BDA_ANTENNA) )
+ {
+ *pulDataSize = sizeof( KS_DATARANGE_BDA_ANTENNA );
+ ntStatus = STATUS_BUFFER_OVERFLOW;
+ goto ExitDataFormat;
+ }
+ else if (pDataRange->FormatSize < sizeof (KS_DATARANGE_BDA_ANTENNA))
+ {
+ ntStatus = STATUS_NO_MATCH;
+ goto ExitDataFormat;
+ }
+ else
+ {
+ *pulDataSize = sizeof( KS_DATARANGE_BDA_ANTENNA );
+ RtlCopyMemory( pData, (PVOID)pDataRange, sizeof(KS_DATARANGE_BDA_ANTENNA));
+ ntStatus = STATUS_SUCCESS;
+ }
+
+ExitDataFormat:
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+
+}
+
+/*****************************************************************************
+ Function : CAntennaPin::PinSetDeviceState
+ Description : An AVStream minidriver's AVStrMiniPinSetDeviceState
+ routine is called when the state of a KSPIN structure is
+ changed due to the arrival of a connection state property
+ 'set' IOCTL. Typically, this will be provided by minidrivers
+ that need to change the state of hardware.
+
+ The KSSTATE enumeration lists possible states of a kernel
+ streaming object.
+ typedef enum {
+ KSSTATE_STOP;
+ KSSTATE_ACQUIRE;
+ KSSTATE_PAUSE;
+ KSSTATE_RUN;
+ } KSSTATE;
+
+ Enumerators
+ KSSTATE_STOP
+ Indicates that the object is in minimum resource consumption mode.
+ KSSTATE_ACQUIRE
+ Indicates that the object is acquiring resources.
+ KSSTATE_PAUSE
+ Indicates that the object is preparing to make instant transition to Run state.
+ KSSTATE_RUN
+ Indicates that the object is actively streaming.
+
+ Because the most upstream pin (input pin) is the last
+ to transition, use this pin's state to set the state
+ of the filter.
+ Also, release filter resouces if the pin's state
+ transitions to stop, and acquire resources if the pin's
+ state transitions from stop.
+ IN PARAM : Pointer to the KSPIN structure for which state is changing.
+ The target KSSTATE after receipt of the IOCTL.
+ The previous KSSTATE.
+ OUT PARAM : Status of the PinSetDeviceState
+ PreCondition : None
+ PostCondtion : None
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CAntennaPin::PinSetDeviceState(
+ IN PKSPIN pKSPin,
+ IN KSSTATE ToState,
+ IN KSSTATE FromState
+ )
+{
+ NTSTATUS ntSetStatus = STATUS_SUCCESS;
+ PKSDEVICE pKSDevice = NULL;
+ CAntennaPin * pPin = NULL;
+ CSkyWalker1Device * pDevice = NULL;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Obtain a pointer to the device object from
+ //the passed in pointer to the KSPIN structure.
+ pKSDevice = KsPinGetDevice( pKSPin);
+
+ //Obtain a pointer to the pin object from context member of
+ //the passed in pointer to the KSPIN structure.
+ pPin = reinterpret_cast(pKSPin->Context);
+
+ //Obtain a pointer to the device object from context member of
+ //the retrieved pointer to the KSDEVICE structure.
+ pDevice = reinterpret_cast(pKSDevice->Context);
+
+ pPin->m_pFilter->SetDeviceState( pPin->m_KsState);
+
+ if ((ToState == KSSTATE_STOP) && (FromState != KSSTATE_STOP))
+ {
+ //Because the driver allocates resources on a filter wide basis,
+ //inform the filter to release resources when the last pin
+ //(that is, the most upstream pin) transitions to the stop state.
+ //
+ //The input pin is the last pin to transition to the stop state,
+ //therefore inform the filter to release its resources.
+ //
+ ntSetStatus = pPin->m_pFilter->ReleaseResources();
+ pPin->m_KsState = ToState;
+ }
+ else if ((ToState == KSSTATE_ACQUIRE) && (FromState == KSSTATE_STOP))
+ {
+ //Because the driver allocates resources on a filter wide basis,
+ //inform the filter to acquire resources when the last pin
+ //(that is, the most upstream pin) transitions from the stop state.
+ //
+ //The input pin is the last pin to transition from the stop state,
+ //therefore inform the filter to acquire its resources.
+ //
+ ntSetStatus = pPin->m_pFilter->AcquireResources();
+ if (NT_SUCCESS( ntSetStatus))
+ {
+ pPin->m_KsState = ToState;
+ }
+ }
+ else if (ToState > KSSTATE_RUN)
+ {
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,
+ ("Invalid Device State. ToState 0x%08x. FromState 0x%08x.",
+ ToState, FromState));
+ ntSetStatus = STATUS_INVALID_PARAMETER;
+ }
+ else
+ {
+ pPin->m_KsState = ToState;
+ }
+
+ PrintDeviceChangeState(ToState,FromState);
+
+ PrintFunctionExit(__FUNCTION__,ntSetStatus);
+ return ntSetStatus;
+}
+
+
+
+/*****************************************************************************
+ Function : CAntennaPin::GetTunerProperty
+ Description : Retrieves the value of the Tuner node Properties
+ IN PARAM : IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ OUT PULONG pulProperty
+ OUT PARAM : Status SUCCESS in case Valid Property request
+ STATUS_INVALID_PARAMETER in case of Invalid property request
+ Else error from the lower device
+ PreCondition : None
+ PostCondtion : Tuner propery read in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CAntennaPin::GetTunerProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ OUT PULONG pulProperty
+ )
+{
+ NTSTATUS ntGetStatus = STATUS_SUCCESS;
+ CAntennaPin * pPin = NULL;
+ CTunerFilter* pFilter = NULL;
+ BDATUNER_DEVICE_PARAMETER TunerProperty;
+
+ PrintFunctionEntry(__FUNCTION__);
+ //Call the BDA support library to
+ //validate that the node type is associated with the pin.
+
+ //The BdaValidateNodeProperty function validates that a node property
+ //request is associated with a specific pin.
+ ntGetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
+ if (NT_SUCCESS( ntGetStatus))
+ {
+ //Obtain a pointer to the pin object.
+
+ //Because the property dispatch table calls the CAntennaPin::GetTunerProperty()
+ //method directly, the method must retrieve a pointer to the underlying pin object.
+ pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
+
+ //Retrieve the filter context from the pin context.
+ pFilter = pPin->GetFilter();
+
+ ntGetStatus = pFilter->GetTunerProperty(&TunerProperty);
+ //Retrieve the actual filter parameter.
+ switch (pKSProperty->Id)
+ {
+ case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
+ *pulProperty = TunerProperty.ulCarrierFrequency;
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
+ *pulProperty = TunerProperty.ulFrequencyMultiplier;
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
+ *pulProperty = TunerProperty.ulBandWidth;
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_POLARITY:
+ *pulProperty = TunerProperty.Polarity;
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_RANGE:
+ *pulProperty = TunerProperty.ulRange;
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
+ *pulProperty = TunerProperty.ulTransponder;
+ break;
+ default:
+ ntGetStatus = STATUS_INVALID_PARAMETER;
+ break;
+ }
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Get : %s : %ul",GetTunerPropertyString(pKSProperty->Id),*pulProperty));
+
+ PrintFunctionExit(__FUNCTION__,ntGetStatus);
+ return ntGetStatus;
+}
+
+/*****************************************************************************
+ Function : CAntennaPin::SetTunerProperty
+ Description : Sets the value of the Tuner node Freq. Properties
+ IN PARAM : IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ OUT PULONG pulProperty
+ OUT PARAM : Status SUCCESS in case Valid Property request
+ STATUS_INVALID_PARAMETER in case of Invalid property request
+ Else error from the lower device
+ PreCondition : None
+ PostCondtion : Tuner Freq. property read in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CAntennaPin::SetTunerProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ )
+{
+ NTSTATUS ntSetStatus = STATUS_SUCCESS;
+ CAntennaPin * pPin;
+ CTunerFilter* pFilter;
+
+ PrintFunctionEntry(__FUNCTION__);
+ //Call the BDA support library to
+ //validate that the node type is associated with the pin.
+
+ //The BdaValidateNodeProperty function validates that a node property
+ //request is associated with a specific pin.
+ ntSetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
+ if (NT_SUCCESS( ntSetStatus))
+ {
+ //Obtain a pointer to the pin object.
+
+ //Because the property dispatch table calls the CAntennaPin::SetTunerProperty()
+ //method directly, the method must retrieve a pointer to the underlying pin object.
+ pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
+
+ //Retrieve the filter context from the pin context.
+ pFilter = pPin->GetFilter();
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Set : %s : %lu\n",
+ GetTunerPropertyString(pKSProperty->Id),
+ *pulProperty));
+ //Retrieve the actual filter parameter.
+ switch (pKSProperty->Id)
+ {
+ case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
+ ntSetStatus = pFilter->SetFrequency(*pulProperty);
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
+ ntSetStatus = pFilter->SetMultiplier(*pulProperty);
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
+ ntSetStatus = pFilter->SetBandwidth(*pulProperty);
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_POLARITY:
+ ntSetStatus = pFilter->SetPolarity((Polarisation) *pulProperty);
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_RANGE:
+ ntSetStatus = pFilter->SetRange(*pulProperty);
+ break;
+ case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
+ ntSetStatus = pFilter->SetTransponder(*pulProperty);
+ break;
+ default:
+ ntSetStatus = STATUS_INVALID_PARAMETER;
+ break;
+ }
+ }
+
+ PrintFunctionExit(__FUNCTION__,ntSetStatus);
+ return ntSetStatus;
+}
+
+/*****************************************************************************
+ Function : CAntennaPin::GetTunerLnbProperty
+ Description : Retrieves the value of the Tuner Lnb node Properties
+ IN PARAM : IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ OUT PULONG pulProperty
+ OUT PARAM : Status SUCCESS in case Valid Property request
+ STATUS_INVALID_PARAMETER in case of Invalid property request
+ Else error from the lower device
+ PreCondition : None
+ PostCondtion : Tuner lnb propery read in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CAntennaPin::GetTunerLnbProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ OUT PULONG pulProperty
+ )
+{
+ NTSTATUS ntGetStatus = STATUS_SUCCESS;
+ CAntennaPin * pPin;
+ CTunerFilter* pFilter;
+ BDATUNER_DEVICE_PARAMETER LnbProperty;
+
+ PrintFunctionEntry(__FUNCTION__);
+ //Call the BDA support library to
+ //validate that the node type is associated with the pin.
+
+ //The BdaValidateNodeProperty function validates that a node property
+ //request is associated with a specific pin.
+ ntGetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
+ if (NT_SUCCESS( ntGetStatus))
+ {
+ //Obtain a pointer to the pin object.
+
+ //Because the property dispatch table calls the CAntennaPin::GetTunerProperty()
+ //method directly, the method must retrieve a pointer to the underlying pin object.
+ pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
+
+ //Retrieve the filter context from the pin context.
+ pFilter = pPin->GetFilter();
+
+ ntGetStatus = pFilter->GetTunerProperty(&LnbProperty);
+
+ //Retrieve the actual filter parameter.
+ switch (pKSProperty->Id)
+ {
+ case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
+ *pulProperty = LnbProperty.ulLnbLowLOFrequency;
+ break;
+ case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
+ *pulProperty = LnbProperty.ulLnbHighLOFrequency;
+ break;
+ case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
+ *pulProperty = LnbProperty.ulLnbSwitchFrequency;
+ break;
+ default:
+ ntGetStatus = STATUS_INVALID_PARAMETER;
+ break;
+ }
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Get : %s : %ul",GetTunerLnbPropertyString(pKSProperty->Id),*pulProperty));
+
+ PrintFunctionExit(__FUNCTION__,ntGetStatus);
+ return ntGetStatus;
+}
+
+/*****************************************************************************
+ Function : CAntennaPin::SetTunerLnbProperty
+ Description : Sets the value of the Tuner Lnb node Properties
+ IN PARAM : IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ OUT PARAM : Status SUCCESS in case Valid Property request
+ STATUS_INVALID_PARAMETER in case of Invalid property request
+ Else error from the lower device
+ PreCondition : None
+ PostCondtion : Tuner propery Set in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CAntennaPin::SetTunerLnbProperty(
+ IN PIRP pIoRequestPacket,
+ IN PKSPROPERTY pKSProperty,
+ IN PULONG pulProperty
+ )
+{
+ NTSTATUS ntSetStatus = STATUS_SUCCESS;
+ CAntennaPin * pPin;
+ CTunerFilter* pFilter;
+
+ PrintFunctionEntry(__FUNCTION__);
+ //Call the BDA support library to
+ //validate that the node type is associated with the pin.
+
+ //The BdaValidateNodeProperty function validates that a node property
+ //request is associated with a specific pin.
+ ntSetStatus = BdaValidateNodeProperty( pIoRequestPacket, pKSProperty);
+ if (NT_SUCCESS( ntSetStatus))
+ {
+ //Obtain a pointer to the pin object.
+
+ //Because the property dispatch table calls the CAntennaPin::SetTunerProperty()
+ //method directly, the method must retrieve a pointer to the underlying pin object.
+
+ pPin = reinterpret_cast(KsGetPinFromIrp(pIoRequestPacket)->Context);
+
+ //Retrieve the filter context from the pin context.
+ pFilter = pPin->GetFilter();
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Set : %s : %lu(%l)",
+ GetTunerLnbPropertyString(pKSProperty->Id),
+ *pulProperty,
+ *((LONG*)(pulProperty))));
+ //Retrieve the actual filter parameter.
+ switch (pKSProperty->Id)
+ {
+ case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
+ ntSetStatus = pFilter->SetLowLOFrequency(*pulProperty);
+ break;
+ case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
+ ntSetStatus = pFilter->SetHighLOFrequency(*pulProperty);
+ break;
+ case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
+ ntSetStatus = pFilter->SetSwitchFrequency(*pulProperty);
+ break;
+ default:
+ ntSetStatus = STATUS_INVALID_PARAMETER;
+ break;
+ }
+ }
+
+ PrintFunctionExit(__FUNCTION__,ntSetStatus);
+ return ntSetStatus;
+}
+
+
+
+
+PCHAR GetTunerPropertyString(ULONG ulTunerProperty)
+{
+ switch(ulTunerProperty)
+ {
+ case KSPROPERTY_BDA_RF_TUNER_FREQUENCY:
+ return "KSPROPERTY_BDA_RF_TUNER_FREQUENCY";
+ case KSPROPERTY_BDA_RF_TUNER_POLARITY:
+ return "KSPROPERTY_BDA_RF_TUNER_POLARITY";
+ case KSPROPERTY_BDA_RF_TUNER_RANGE:
+ return "KSPROPERTY_BDA_RF_TUNER_RANGE";
+ case KSPROPERTY_BDA_RF_TUNER_TRANSPONDER:
+ return "KSPROPERTY_BDA_RF_TUNER_TRANSPONDER";
+ case KSPROPERTY_BDA_RF_TUNER_BANDWIDTH:
+ return "KSPROPERTY_BDA_RF_TUNER_BANDWIDTH";
+ case KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER:
+ return "KSPROPERTY_BDA_RF_TUNER_FREQUENCY_MULTIPLIER";
+ default:
+ return "KSPROPERTY_BDA_INVALID_PROPERTY";
+ }
+}
+
+PCHAR GetTunerLnbPropertyString(ULONG ulTunerLnbProperty)
+{
+ switch(ulTunerLnbProperty)
+ {
+ case KSPROPERTY_BDA_LNB_LOF_LOW_BAND:
+ return "KSPROPERTY_BDA_LNB_LOF_LOW_BAND";
+ case KSPROPERTY_BDA_LNB_LOF_HIGH_BAND:
+ return "KSPROPERTY_BDA_LNB_LOF_HIGH_BAND";
+ case KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY:
+ return "KSPROPERTY_BDA_LNB_SWITCH_FREQUENCY";
+ default:
+ return "KSPROPERTY_BDA_INVALID_PROPERTY";
+ }
+}
diff --git a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilter.cpp b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilter.cpp
index 304d258..2ddc17f 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilter.cpp
+++ b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilter.cpp
@@ -1,165 +1,165 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1CaptureFilter.cpp
- Author :
- Date :
- Purpose : This file contains the filter level header for the
- capture filter.
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-/* Include the Library and Other header file */
-
-#include "SkyWalker1Main.h" //Main Header file
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-/* End of Function prototype definitions */
-
-/*****************************************************************************
- Function : CCaptureFilter
- Description : Constructor of the CCaptureFilter Class
- The capture filter object constructor. Since the new operator will
- have zeroed the memory, do not bother initializing any NULL or 0
- fields.Only initialize non-NULL, non-0 fields.
- IN PARAM : Filter
- OUT PARAM : NONE
- PreCondition : Filter Object is not created
- PostCondtion : Filter Object is created and Initialzed on successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-CCaptureFilter::CCaptureFilter(IN PKSFILTER pKSFilter) :
- m_Filter (pKSFilter)
-{
-
-}
-
-/*****************************************************************************
- Function : CCaptureFilter
- Description : Destructor of the CCaptureFilter Class
- Destroys the filter object
- IN PARAM : NONE
- OUT PARAM : NONE
- PreCondition : Filter Object is created
- PostCondtion : Filter Object is Removed and Memory freed
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-CCaptureFilter::~CCaptureFilter()
-{
-
-}
-
-/*****************************************************************************
- Function : CCaptureFilter::Cleanup()
- Description : This is the bag cleanup callback for the CCaptureFilter.
- Destroys the filter object
- IN PARAM : Reference to the current Object
- OUT PARAM : NONE
- PreCondition : Filter Object is created
- PostCondtion : Filter Object is Removed and Memory freed
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-void CCaptureFilter::Cleanup (IN CCaptureFilter *pFilter)
-{
- delete pFilter;
-}
-
-
-/*****************************************************************************
- Function : CCaptureFilter::Create()
- Description : It creates the CCaptureFilter object, associates it with
- the AVStream filter object, and bag the CCaptureFilter
- for later cleanup.
- IN PARAM : Pointer to KSFILTER that just created
- Pointer to IRP_MJ_CREATE for Filter
- OUT PARAM : Status of the Filter Create routine
- STATUS_SUCCESS on Routine success
- Else Error code from the attempt to create the Filter
- PreCondition : Filter is not created
- PostCondtion : Filter is created and Initialzed on successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-STDMETHODIMP_(NTSTATUS) CCaptureFilter::Create( IN OUT PKSFILTER pKSFilter,
- IN PIRP pIoRequestPacket)
-{
- NTSTATUS ntFilterCreationStatus = STATUS_SUCCESS;
- ULONG ulPinId; // just useful when no network provider is present
- PKSDEVICE pKSDeviceObject = NULL;
- CSkyWalker1Device * pDevice = NULL;
-
- PrintFunctionEntry(__FUNCTION__);
-
- //Create a filter object for the filter instance.
- CCaptureFilter* pFilter = new(NonPagedPool,CAPTURE_MEM_TAG) CCaptureFilter(pKSFilter); // Tags the allocated memory
- if (!IS_VALID(pFilter))
- {
- //Exit if the Filter Memory could not be allocated
- ntFilterCreationStatus = STATUS_INSUFFICIENT_RESOURCES;
- goto ErrorFilterCreate;
- }
- else
- {
- // Add the item to the object bag if we we were successful.
- // Whenever the filter closes, the bag is cleaned up and we will be
- // freed.
- //
- ntFilterCreationStatus = KsAddItemToObjectBag (
- pKSFilter -> Bag,
- reinterpret_cast (pFilter),
- reinterpret_cast (CCaptureFilter::Cleanup)
- );
-
- if (!NT_SUCCESS (ntFilterCreationStatus))
- {
- goto ErrorFilterCreate;
- }
- else
- {
- pKSFilter->Context = reinterpret_cast (pFilter);
- }
- }
-
-CompleteFilterCreate :
-
- PrintFunctionExit(__FUNCTION__,ntFilterCreationStatus);
- return ntFilterCreationStatus;
-
-ErrorFilterCreate:
- if (IS_VALID(pFilter))
- {
- delete pFilter;
- }
-
- goto CompleteFilterCreate;
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1CaptureFilter.cpp
+ Author :
+ Date :
+ Purpose : This file contains the filter level header for the
+ capture filter.
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+/* Include the Library and Other header file */
+
+#include "SkyWalker1Main.h" //Main Header file
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+/* End of Function prototype definitions */
+
+/*****************************************************************************
+ Function : CCaptureFilter
+ Description : Constructor of the CCaptureFilter Class
+ The capture filter object constructor. Since the new operator will
+ have zeroed the memory, do not bother initializing any NULL or 0
+ fields.Only initialize non-NULL, non-0 fields.
+ IN PARAM : Filter
+ OUT PARAM : NONE
+ PreCondition : Filter Object is not created
+ PostCondtion : Filter Object is created and Initialzed on successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+CCaptureFilter::CCaptureFilter(IN PKSFILTER pKSFilter) :
+ m_Filter (pKSFilter)
+{
+
+}
+
+/*****************************************************************************
+ Function : CCaptureFilter
+ Description : Destructor of the CCaptureFilter Class
+ Destroys the filter object
+ IN PARAM : NONE
+ OUT PARAM : NONE
+ PreCondition : Filter Object is created
+ PostCondtion : Filter Object is Removed and Memory freed
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+CCaptureFilter::~CCaptureFilter()
+{
+
+}
+
+/*****************************************************************************
+ Function : CCaptureFilter::Cleanup()
+ Description : This is the bag cleanup callback for the CCaptureFilter.
+ Destroys the filter object
+ IN PARAM : Reference to the current Object
+ OUT PARAM : NONE
+ PreCondition : Filter Object is created
+ PostCondtion : Filter Object is Removed and Memory freed
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+void CCaptureFilter::Cleanup (IN CCaptureFilter *pFilter)
+{
+ delete pFilter;
+}
+
+
+/*****************************************************************************
+ Function : CCaptureFilter::Create()
+ Description : It creates the CCaptureFilter object, associates it with
+ the AVStream filter object, and bag the CCaptureFilter
+ for later cleanup.
+ IN PARAM : Pointer to KSFILTER that just created
+ Pointer to IRP_MJ_CREATE for Filter
+ OUT PARAM : Status of the Filter Create routine
+ STATUS_SUCCESS on Routine success
+ Else Error code from the attempt to create the Filter
+ PreCondition : Filter is not created
+ PostCondtion : Filter is created and Initialzed on successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+STDMETHODIMP_(NTSTATUS) CCaptureFilter::Create( IN OUT PKSFILTER pKSFilter,
+ IN PIRP pIoRequestPacket)
+{
+ NTSTATUS ntFilterCreationStatus = STATUS_SUCCESS;
+ ULONG ulPinId; // just useful when no network provider is present
+ PKSDEVICE pKSDeviceObject = NULL;
+ CSkyWalker1Device * pDevice = NULL;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Create a filter object for the filter instance.
+ CCaptureFilter* pFilter = new(NonPagedPool,CAPTURE_MEM_TAG) CCaptureFilter(pKSFilter); // Tags the allocated memory
+ if (!IS_VALID(pFilter))
+ {
+ //Exit if the Filter Memory could not be allocated
+ ntFilterCreationStatus = STATUS_INSUFFICIENT_RESOURCES;
+ goto ErrorFilterCreate;
+ }
+ else
+ {
+ // Add the item to the object bag if we we were successful.
+ // Whenever the filter closes, the bag is cleaned up and we will be
+ // freed.
+ //
+ ntFilterCreationStatus = KsAddItemToObjectBag (
+ pKSFilter -> Bag,
+ reinterpret_cast (pFilter),
+ reinterpret_cast (CCaptureFilter::Cleanup)
+ );
+
+ if (!NT_SUCCESS (ntFilterCreationStatus))
+ {
+ goto ErrorFilterCreate;
+ }
+ else
+ {
+ pKSFilter->Context = reinterpret_cast (pFilter);
+ }
+ }
+
+CompleteFilterCreate :
+
+ PrintFunctionExit(__FUNCTION__,ntFilterCreationStatus);
+ return ntFilterCreationStatus;
+
+ErrorFilterCreate:
+ if (IS_VALID(pFilter))
+ {
+ delete pFilter;
+ }
+
+ goto CompleteFilterCreate;
}
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilterDefinitions.cpp b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilterDefinitions.cpp
index 91f7ad2..29c3cd6 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilterDefinitions.cpp
+++ b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CaptureFilterDefinitions.cpp
@@ -1,336 +1,336 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1CaptureFilterDefinitions.cpp
- Author :
- Date :
- Purpose : Capture Filter Definition
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-/* Include the Library and Other header file */
-
-#include "SkyWalker1Main.h" //Main Header file
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-
-const KSPIN_DISPATCH CaptureInputPinDispatch={
- /* Create */ CCapturePin::PinCreate,
- /* Close */ NULL,
- /* Process */ NULL,
- /* Reset */ NULL,
- /* SetDataFormat */ NULL,
- /* SetDeviceState */ NULL,
- /* Connect */ NULL,
- /* Disconnect */ NULL,
- /* Allocator */ NULL
-};
-
-DEFINE_KSAUTOMATION_TABLE(NullAutomation) {
- DEFINE_KSAUTOMATION_PROPERTIES_NULL,
- DEFINE_KSAUTOMATION_METHODS_NULL,
- DEFINE_KSAUTOMATION_EVENTS_NULL
-};
-
-//The list of category GUIDs for the capture filter.
-const GUID SkyWalker1CaptureCatagories [] = {
- STATICGUIDOF (KSCATEGORY_BDA_RECEIVER_COMPONENT)
-};
-
-//Medium GUIDs for the Transport Output Pin.
-//
-//Pin Medium descriptor containing all medium accepted to be connected to
-//the tuner output pin.This insures contection to the correct Capture Filter pin.
-//
-//{2AEB4A94-FBB7-4FB1-8D74-243B91886EAB}
-
-const KSPIN_MEDIUM TransportPinMediums[] =
-{
- {
- GUID_SKYWALKER_TUNER_OUT_MEDIUM,
- 0,
- 0
- }
-};
-
-//
-//This is the data range description of the capture input pin.
-//This is same as the Outpin of the Tuner i.e. The Transport Pin
-//The Output of the Tuner is given to the Capture thus it has to
-//be same
-//
-const KS_DATARANGE_BDA_TRANSPORT FormatCaptureIn =
-{
- //insert the KSDATARANGE and KSDATAFORMAT here
- {
- sizeof( KS_DATARANGE_BDA_TRANSPORT), //FormatSize
- 0, //Flags - (N/A)
- 0, //SampleSize - (N/A)
- 0, //Reserved
- { STATIC_KSDATAFORMAT_TYPE_STREAM }, //MajorFormat
- { STATIC_KSDATAFORMAT_TYPE_MPEG2_TRANSPORT }, //SubFormat
- { STATIC_KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT } //Specifier
- },
- //insert the BDA_TRANSPORT_INFO here
- {
- TRANSPORT_PACKET_SIZE, //ulcbPhyiscalPacket
- TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE, //ulcbPhyiscalFrame
- 0, //ulcbPhyiscalFrameAlignment (no requirement)
- 0 //AvgTimePerFrame (not known)
- }
-};
-
-const PKSDATARANGE CaptureInPinDataRanges[]={
- (PKSDATARANGE)&FormatCaptureIn,
-};
-
-//Capture Outout Pin Definitions
-const KSPIN_DISPATCH CaptureOutputPinDispatch={
- /* Create */ CCapturePin::PinCreate,
- /* Close */ NULL,
- /* Process */ CCapturePin::DispatchProcess,
- /* Reset */ NULL,
- /* SetDataFormat */ NULL,
- /* SetDeviceState */ CCapturePin::DispatchSetState,
- /* Connect */ NULL,
- /* Disconnect */ NULL,
- /* Allocator */ NULL
-};
-
-
-//
-//This is the data range description of the capture output pin.
-//
-const KSDATARANGE FormatCaptureOut =
-{
- //insert the KSDATARANGE and KSDATAFORMAT here
- {
- sizeof( KSDATARANGE), //FormatSize
- 0, //Flags - (N/A)
- TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE, //SampleSize
- 0, //Reserved
- { STATIC_KSDATAFORMAT_TYPE_STREAM }, //MajorFormat
- { STATIC_KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT },//SubFormat
- { STATIC_KSDATAFORMAT_SPECIFIER_NONE } //Specifier
- }
-};
-
-const PKSDATARANGE CaptureOutPinDataRanges[]={
- (PKSDATARANGE)&FormatCaptureOut,
-};
-
-//
-//CapturePinAllocatorFraming:
-//
-//This is the simple framing structure for the capture pin. Note that this
-//will be modified via KsEdit when the actual capture format is determined.
-//
-DECLARE_SIMPLE_FRAMING_EX (
- CapturePinAllocatorFraming, //FramingExName
- STATICGUIDOF (KSMEMORY_TYPE_KERNEL_NONPAGED), //MemoryType
- KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY |
- KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY, //Flags
- NUMBER_OF_FRAMES, //Frames
- 0, //Alignment
- TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE, //MinFrameSize
- TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE //MaxFrameSize
- );
-
-/**********************************************************************************/
-
-//Not Supporting Filter Methods,Properties and Events
-DEFINE_KSAUTOMATION_TABLE(SkyWalker1CaptureAutomationTable)
-{
- DEFINE_KSAUTOMATION_PROPERTIES_NULL,
- DEFINE_KSAUTOMATION_METHODS_NULL,
- DEFINE_KSAUTOMATION_EVENTS_NULL
-};
-/**********************************************************************************/
-//
-//CaptureFilterDispatch:
-//
-//This is the dispatch table for the capture filter. It provides notification
-//of creation, closure, processing (for filter-centrics, not for the capture
-//filter), and resets (for filter-centrics, not for the capture filter).
-//
-const KSFILTER_DISPATCH SkyWalker1CaptureDispatchTable =
-{
- /* Create */ CCaptureFilter::Create, //Routine called when the Filter is created
- /* Close */ NULL, //Routine called when the Filter is closed
- /* Process */ NULL,
- /* Reset */ NULL
-};
-
-//
-//Capture Pin Descriptors
-//
-//This data structure defines the pin types available in the filters
-//template topology. These structures will be used to create a
-//KDPinFactory for a pin type when BdaCreatePin or BdaMethodCreatePin
-//are called.
-//
-//This structure defines ALL pins the filter is capable of supporting,
-//including those pins which may only be created dynamically by a ring
-//3 component such as a Network Provider.
-
-//The list of pin descriptors on the capture filter.
-const KSPIN_DESCRIPTOR_EX SkyWalker1CapturePinDescriptors[]={
- { //Capture Filter input pin
- &CaptureInputPinDispatch, //Dispatch Table
- &NullAutomation, //Automation Table
- {
- 0, //Interfaces
- NULL,
- SIZEOF_ARRAY(TransportPinMediums), //Medium Count
- TransportPinMediums, //Medium
- SIZEOF_ARRAY(CaptureInPinDataRanges), //Range Count
- CaptureInPinDataRanges, //Ranges
- KSPIN_DATAFLOW_IN, //Specifies that data flow is into the pin
- KSPIN_COMMUNICATION_BOTH, //Specifies that the pin factory instantiates pins
- //that are both IRP sinks and IRP sources
- (GUID *) &PINNAME_BDA_TRANSPORT, //Category GUID
- (GUID *) &PINNAME_BDA_TRANSPORT, //GUID of the localized Unicode string
- 0
- },
- KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT|
- KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING|
- KSPIN_FLAG_FIXED_FORMAT,
- 1, //Maximum Possible Instances of the Pin
- 1, //Mandatory Instances of this for the Filter function
- NULL,//Allocator Framing
- NULL //Data Interaction Handler
- },
- { //Capture Filter output pin
- &CaptureOutputPinDispatch, //Dispatch Table
- &NullAutomation, //Automation Table
- {
- NULL,
- 0,
- NULL,
- 0,
- SIZEOF_ARRAY(CaptureOutPinDataRanges), //Range Count
- CaptureOutPinDataRanges,
- KSPIN_DATAFLOW_OUT, //Specifies that data flow is out of the pin
- KSPIN_COMMUNICATION_BOTH,//Specifies that the pin factory instantiates pins
- //that are both IRP sinks and IRP sources
- (GUID *) &PINNAME_BDA_TRANSPORT, //Category GUID
- (GUID *) &PINNAME_BDA_TRANSPORT, //GUID of the localized Unicode string
- 0
- },
-#if !defined(_BUILD_SW_TUNER_ON_X64)
- KSPIN_FLAG_GENERATE_MAPPINGS | //Pin Flags
-#endif
- KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,
- 1,//Maximum Possible Instances of the Pin
- 1,//Mandatory Instances of this for the Filter function
- &CapturePinAllocatorFraming,
- NULL
- },
-};
-
-
-/*****************************************************************************************/
-//Define BDA Template Topology Connections
-//
-//Lists the Connections that are possible between pin types and
-//node types. This, together with the Template Filter Descriptor, and
-//the Pin Pairings, describe how topologies can be created in the filter.
-//
-// =================
-//TransportPin ----| Capture Filter |
-// =================
-//
-//The Capture Filter is controlled by the Transport input pin.
-//Capture Filter properties will be set as NODE properties (with NodeType == 0)
-//on the filter's Tranport Pin
-//
-const KSTOPOLOGY_CONNECTION SkyWalker1CaptureConnections[]={
- {KSFILTER_NODE, 0, KSFILTER_NODE, KSNODEPIN_STANDARD_IN}, //Transport pin -> Capture Filter pin 0
-};
-
-/*****************************************************************************************/
-
-//Define the Filter Factory Descriptor for the filter
-//This structure brings together all of the structures that define
-//the tuner filter as it appears when it is first instantiated.
-//Note that not all of the template pin and node types may be exposed as
-//pin and node factories when the filter is first instanciated.
-
-//The KSFILTER_DESCRIPTOR structure describes the characteristics of a filter created by a given filter factory.
-DEFINE_KSFILTER_DESCRIPTOR(SkyWalker1CaptureFilterDescriptor)
-{
- &SkyWalker1CaptureDispatchTable, //Dispatch (Filter Specific Driver)
- NULL, //AutomationTable
- KSFILTER_DESCRIPTOR_VERSION, //Version
- 0, //Flags
- &SKYWALKER_CAPTURE_FILTER, //ReferenceGuid
- DEFINE_KSFILTER_PIN_DESCRIPTORS(SkyWalker1CapturePinDescriptors),
- //PinDescriptorsCount; must expose at least one pin
- //PinDescriptorSize; size of each item
- //PinDescriptors; table of pin descriptors
- DEFINE_KSFILTER_CATEGORY(KSCATEGORY_BDA_RECEIVER_COMPONENT),
- //CategoriesCount; number of categories in the table
- //Categories; table of categories
- DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL,
- //NodeDescriptorsCount;
- //NodeDescriptorSize;
- //NodeDescriptors;
- DEFINE_KSFILTER_CONNECTIONS(SkyWalker1CaptureConnections),
- //Automatically fills in the connections table for a filter which defines no explicit connections
- //ConnectionsCount; number of connections in the table
- //Connections; table of connections
- NULL //ComponentId;
-};
-
-//Array of BDA_PIN_PAIRING structures that are used to determine
-//which nodes get duplicated when more than one output pin type is
-//connected to a single input pin type or when more that one input pin
-//type is connected to a single output pin type.
-//
-const BDA_PIN_PAIRING SkyWalker1CapturePinPairings[] =
-{
- //Input pin to Output pin Topology Joints
- //
- {
- 0, //ulInputPin; 0 element in the TemplatePinDescriptors array.
- 1, //ulOutputPin; 1 element in the TemplatePinDescriptors array.
- 1, //ulcMaxInputsPerOutput
- 1, //ulcMinInputsPerOutput
- 1, //ulcMaxOutputsPerInput
- 1, //ulcMinOutputsPerInput
- 0, //ulcTopologyJoints
- NULL //pTopologyJoints; array of joints
- }
- //If applicable, list topology of joints between other pins.
- //
-};
-
-
-//BDA_FILTER_TEMPLATE structure describes the template topology for BDA Driver
-const BDA_FILTER_TEMPLATE SkyWalker1CaptureTemplate =
-{
- &SkyWalker1CaptureFilterDescriptor,//Pointer to KS_FILTER_DESCRIPTOR which describes the Filter for BDA Device
- SIZEOF_ARRAY(SkyWalker1CapturePinPairings), //Number of PAIRS of pins in BDA_PIN_PAIRING Array
- SkyWalker1CapturePinPairings //Array of Pin Pairing describes topology between a pair of Filter's Input and Output Pins
-};
-
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1CaptureFilterDefinitions.cpp
+ Author :
+ Date :
+ Purpose : Capture Filter Definition
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+/* Include the Library and Other header file */
+
+#include "SkyWalker1Main.h" //Main Header file
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+
+const KSPIN_DISPATCH CaptureInputPinDispatch={
+ /* Create */ CCapturePin::PinCreate,
+ /* Close */ NULL,
+ /* Process */ NULL,
+ /* Reset */ NULL,
+ /* SetDataFormat */ NULL,
+ /* SetDeviceState */ NULL,
+ /* Connect */ NULL,
+ /* Disconnect */ NULL,
+ /* Allocator */ NULL
+};
+
+DEFINE_KSAUTOMATION_TABLE(NullAutomation) {
+ DEFINE_KSAUTOMATION_PROPERTIES_NULL,
+ DEFINE_KSAUTOMATION_METHODS_NULL,
+ DEFINE_KSAUTOMATION_EVENTS_NULL
+};
+
+//The list of category GUIDs for the capture filter.
+const GUID SkyWalker1CaptureCatagories [] = {
+ STATICGUIDOF (KSCATEGORY_BDA_RECEIVER_COMPONENT)
+};
+
+//Medium GUIDs for the Transport Output Pin.
+//
+//Pin Medium descriptor containing all medium accepted to be connected to
+//the tuner output pin.This insures contection to the correct Capture Filter pin.
+//
+//{2AEB4A94-FBB7-4FB1-8D74-243B91886EAB}
+
+const KSPIN_MEDIUM TransportPinMediums[] =
+{
+ {
+ GUID_SKYWALKER_TUNER_OUT_MEDIUM,
+ 0,
+ 0
+ }
+};
+
+//
+//This is the data range description of the capture input pin.
+//This is same as the Outpin of the Tuner i.e. The Transport Pin
+//The Output of the Tuner is given to the Capture thus it has to
+//be same
+//
+const KS_DATARANGE_BDA_TRANSPORT FormatCaptureIn =
+{
+ //insert the KSDATARANGE and KSDATAFORMAT here
+ {
+ sizeof( KS_DATARANGE_BDA_TRANSPORT), //FormatSize
+ 0, //Flags - (N/A)
+ 0, //SampleSize - (N/A)
+ 0, //Reserved
+ { STATIC_KSDATAFORMAT_TYPE_STREAM }, //MajorFormat
+ { STATIC_KSDATAFORMAT_TYPE_MPEG2_TRANSPORT }, //SubFormat
+ { STATIC_KSDATAFORMAT_SPECIFIER_BDA_TRANSPORT } //Specifier
+ },
+ //insert the BDA_TRANSPORT_INFO here
+ {
+ TRANSPORT_PACKET_SIZE, //ulcbPhyiscalPacket
+ TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE, //ulcbPhyiscalFrame
+ 0, //ulcbPhyiscalFrameAlignment (no requirement)
+ 0 //AvgTimePerFrame (not known)
+ }
+};
+
+const PKSDATARANGE CaptureInPinDataRanges[]={
+ (PKSDATARANGE)&FormatCaptureIn,
+};
+
+//Capture Outout Pin Definitions
+const KSPIN_DISPATCH CaptureOutputPinDispatch={
+ /* Create */ CCapturePin::PinCreate,
+ /* Close */ NULL,
+ /* Process */ CCapturePin::DispatchProcess,
+ /* Reset */ NULL,
+ /* SetDataFormat */ NULL,
+ /* SetDeviceState */ CCapturePin::DispatchSetState,
+ /* Connect */ NULL,
+ /* Disconnect */ NULL,
+ /* Allocator */ NULL
+};
+
+
+//
+//This is the data range description of the capture output pin.
+//
+const KSDATARANGE FormatCaptureOut =
+{
+ //insert the KSDATARANGE and KSDATAFORMAT here
+ {
+ sizeof( KSDATARANGE), //FormatSize
+ 0, //Flags - (N/A)
+ TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE, //SampleSize
+ 0, //Reserved
+ { STATIC_KSDATAFORMAT_TYPE_STREAM }, //MajorFormat
+ { STATIC_KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT },//SubFormat
+ { STATIC_KSDATAFORMAT_SPECIFIER_NONE } //Specifier
+ }
+};
+
+const PKSDATARANGE CaptureOutPinDataRanges[]={
+ (PKSDATARANGE)&FormatCaptureOut,
+};
+
+//
+//CapturePinAllocatorFraming:
+//
+//This is the simple framing structure for the capture pin. Note that this
+//will be modified via KsEdit when the actual capture format is determined.
+//
+DECLARE_SIMPLE_FRAMING_EX (
+ CapturePinAllocatorFraming, //FramingExName
+ STATICGUIDOF (KSMEMORY_TYPE_KERNEL_NONPAGED), //MemoryType
+ KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY |
+ KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY, //Flags
+ NUMBER_OF_FRAMES, //Frames
+ 0, //Alignment
+ TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE, //MinFrameSize
+ TRANSPORT_PACKET_COUNT*TRANSPORT_PACKET_SIZE //MaxFrameSize
+ );
+
+/**********************************************************************************/
+
+//Not Supporting Filter Methods,Properties and Events
+DEFINE_KSAUTOMATION_TABLE(SkyWalker1CaptureAutomationTable)
+{
+ DEFINE_KSAUTOMATION_PROPERTIES_NULL,
+ DEFINE_KSAUTOMATION_METHODS_NULL,
+ DEFINE_KSAUTOMATION_EVENTS_NULL
+};
+/**********************************************************************************/
+//
+//CaptureFilterDispatch:
+//
+//This is the dispatch table for the capture filter. It provides notification
+//of creation, closure, processing (for filter-centrics, not for the capture
+//filter), and resets (for filter-centrics, not for the capture filter).
+//
+const KSFILTER_DISPATCH SkyWalker1CaptureDispatchTable =
+{
+ /* Create */ CCaptureFilter::Create, //Routine called when the Filter is created
+ /* Close */ NULL, //Routine called when the Filter is closed
+ /* Process */ NULL,
+ /* Reset */ NULL
+};
+
+//
+//Capture Pin Descriptors
+//
+//This data structure defines the pin types available in the filters
+//template topology. These structures will be used to create a
+//KDPinFactory for a pin type when BdaCreatePin or BdaMethodCreatePin
+//are called.
+//
+//This structure defines ALL pins the filter is capable of supporting,
+//including those pins which may only be created dynamically by a ring
+//3 component such as a Network Provider.
+
+//The list of pin descriptors on the capture filter.
+const KSPIN_DESCRIPTOR_EX SkyWalker1CapturePinDescriptors[]={
+ { //Capture Filter input pin
+ &CaptureInputPinDispatch, //Dispatch Table
+ &NullAutomation, //Automation Table
+ {
+ 0, //Interfaces
+ NULL,
+ SIZEOF_ARRAY(TransportPinMediums), //Medium Count
+ TransportPinMediums, //Medium
+ SIZEOF_ARRAY(CaptureInPinDataRanges), //Range Count
+ CaptureInPinDataRanges, //Ranges
+ KSPIN_DATAFLOW_IN, //Specifies that data flow is into the pin
+ KSPIN_COMMUNICATION_BOTH, //Specifies that the pin factory instantiates pins
+ //that are both IRP sinks and IRP sources
+ (GUID *) &PINNAME_BDA_TRANSPORT, //Category GUID
+ (GUID *) &PINNAME_BDA_TRANSPORT, //GUID of the localized Unicode string
+ 0
+ },
+ KSPIN_FLAG_DO_NOT_USE_STANDARD_TRANSPORT|
+ KSPIN_FLAG_FRAMES_NOT_REQUIRED_FOR_PROCESSING|
+ KSPIN_FLAG_FIXED_FORMAT,
+ 1, //Maximum Possible Instances of the Pin
+ 1, //Mandatory Instances of this for the Filter function
+ NULL,//Allocator Framing
+ NULL //Data Interaction Handler
+ },
+ { //Capture Filter output pin
+ &CaptureOutputPinDispatch, //Dispatch Table
+ &NullAutomation, //Automation Table
+ {
+ NULL,
+ 0,
+ NULL,
+ 0,
+ SIZEOF_ARRAY(CaptureOutPinDataRanges), //Range Count
+ CaptureOutPinDataRanges,
+ KSPIN_DATAFLOW_OUT, //Specifies that data flow is out of the pin
+ KSPIN_COMMUNICATION_BOTH,//Specifies that the pin factory instantiates pins
+ //that are both IRP sinks and IRP sources
+ (GUID *) &PINNAME_BDA_TRANSPORT, //Category GUID
+ (GUID *) &PINNAME_BDA_TRANSPORT, //GUID of the localized Unicode string
+ 0
+ },
+#if !defined(_BUILD_SW_TUNER_ON_X64)
+ KSPIN_FLAG_GENERATE_MAPPINGS | //Pin Flags
+#endif
+ KSPIN_FLAG_PROCESS_IN_RUN_STATE_ONLY,
+ 1,//Maximum Possible Instances of the Pin
+ 1,//Mandatory Instances of this for the Filter function
+ &CapturePinAllocatorFraming,
+ NULL
+ },
+};
+
+
+/*****************************************************************************************/
+//Define BDA Template Topology Connections
+//
+//Lists the Connections that are possible between pin types and
+//node types. This, together with the Template Filter Descriptor, and
+//the Pin Pairings, describe how topologies can be created in the filter.
+//
+// =================
+//TransportPin ----| Capture Filter |
+// =================
+//
+//The Capture Filter is controlled by the Transport input pin.
+//Capture Filter properties will be set as NODE properties (with NodeType == 0)
+//on the filter's Tranport Pin
+//
+const KSTOPOLOGY_CONNECTION SkyWalker1CaptureConnections[]={
+ {KSFILTER_NODE, 0, KSFILTER_NODE, KSNODEPIN_STANDARD_IN}, //Transport pin -> Capture Filter pin 0
+};
+
+/*****************************************************************************************/
+
+//Define the Filter Factory Descriptor for the filter
+//This structure brings together all of the structures that define
+//the tuner filter as it appears when it is first instantiated.
+//Note that not all of the template pin and node types may be exposed as
+//pin and node factories when the filter is first instanciated.
+
+//The KSFILTER_DESCRIPTOR structure describes the characteristics of a filter created by a given filter factory.
+DEFINE_KSFILTER_DESCRIPTOR(SkyWalker1CaptureFilterDescriptor)
+{
+ &SkyWalker1CaptureDispatchTable, //Dispatch (Filter Specific Driver)
+ NULL, //AutomationTable
+ KSFILTER_DESCRIPTOR_VERSION, //Version
+ 0, //Flags
+ &SKYWALKER_CAPTURE_FILTER, //ReferenceGuid
+ DEFINE_KSFILTER_PIN_DESCRIPTORS(SkyWalker1CapturePinDescriptors),
+ //PinDescriptorsCount; must expose at least one pin
+ //PinDescriptorSize; size of each item
+ //PinDescriptors; table of pin descriptors
+ DEFINE_KSFILTER_CATEGORY(KSCATEGORY_BDA_RECEIVER_COMPONENT),
+ //CategoriesCount; number of categories in the table
+ //Categories; table of categories
+ DEFINE_KSFILTER_NODE_DESCRIPTORS_NULL,
+ //NodeDescriptorsCount;
+ //NodeDescriptorSize;
+ //NodeDescriptors;
+ DEFINE_KSFILTER_CONNECTIONS(SkyWalker1CaptureConnections),
+ //Automatically fills in the connections table for a filter which defines no explicit connections
+ //ConnectionsCount; number of connections in the table
+ //Connections; table of connections
+ NULL //ComponentId;
+};
+
+//Array of BDA_PIN_PAIRING structures that are used to determine
+//which nodes get duplicated when more than one output pin type is
+//connected to a single input pin type or when more that one input pin
+//type is connected to a single output pin type.
+//
+const BDA_PIN_PAIRING SkyWalker1CapturePinPairings[] =
+{
+ //Input pin to Output pin Topology Joints
+ //
+ {
+ 0, //ulInputPin; 0 element in the TemplatePinDescriptors array.
+ 1, //ulOutputPin; 1 element in the TemplatePinDescriptors array.
+ 1, //ulcMaxInputsPerOutput
+ 1, //ulcMinInputsPerOutput
+ 1, //ulcMaxOutputsPerInput
+ 1, //ulcMinOutputsPerInput
+ 0, //ulcTopologyJoints
+ NULL //pTopologyJoints; array of joints
+ }
+ //If applicable, list topology of joints between other pins.
+ //
+};
+
+
+//BDA_FILTER_TEMPLATE structure describes the template topology for BDA Driver
+const BDA_FILTER_TEMPLATE SkyWalker1CaptureTemplate =
+{
+ &SkyWalker1CaptureFilterDescriptor,//Pointer to KS_FILTER_DESCRIPTOR which describes the Filter for BDA Device
+ SIZEOF_ARRAY(SkyWalker1CapturePinPairings), //Number of PAIRS of pins in BDA_PIN_PAIRING Array
+ SkyWalker1CapturePinPairings //Array of Pin Pairing describes topology between a pair of Filter's Input and Output Pins
+};
+
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
/* End of Function prototype definitions */
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CapturePin.cpp b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CapturePin.cpp
index ad5680b..9abc931 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CapturePin.cpp
+++ b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1CapturePin.cpp
@@ -1,693 +1,693 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1CapturePin.cpp
- Author :
- Date :
- Purpose : This file contains header for the video capture pin on
- the capture filter.
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-/* Include the Library and Other header file */
-
-#include "SkyWalker1Main.h" //Common For all the Definitions,
- //Declarations and Library Routines
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-VOID PrintStream(IN PKSSTREAM_POINTER pStreamPointer);
-/* End of Function prototype definitions */
-
-
-/*****************************************************************************
- Function : CCapturePin
- Description : Constructor of the CCapturePin Class
- IN PARAM : NONE
- OUT PARAM : NONE
- PreCondition : pKSPin Object is not created
- PostCondtion : pKSPin Object is created and Initialzed on successful execution
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-CCapturePin::CCapturePin(IN PKSPIN pKSPin) :
- m_Pin (pKSPin)
-{
- PKSDEVICE pKSDevice = KsPinGetDevice (pKSPin);
-
- PrintFunctionEntry(__FUNCTION__);
-
- //Set up our device pointer. This gives us access to "Hardware I/O"
- //during the capture routines.
- m_Device = reinterpret_cast (pKSDevice->Context);
-
- PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
-}
-
-/*****************************************************************************
- Function : CCapturePin
- Description : Destructor of the CCapturePin Class
- IN PARAM : NONE
- OUT PARAM : NONE
- PreCondition : pKSPin Object is created
- PostCondtion : pKSPin Object is Removed and Memory freed
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-CCapturePin::~CCapturePin()
-{
- PrintFunctionEntry(__FUNCTION__);
- PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
-}
-
-/*****************************************************************************
- Function : CCapturePin::PinCreate
- Description : An AVStream minidriver's AVStrMiniPinCreate routine is
- called when a pin is created. Typically, this routine is
- used by minidrivers that want to initialize the context
- and resources associated with the pin.
- IN PARAM : Pointer to the KSPIN that was just created.
- Pointer to the IRP_MJ_CREATE for pKSPin
- OUT PARAM : STATUS_SUCCESS in case of successful pin creation
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Create a new capture pin. This is the creation dispatch for
- the video capture pin.
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CCapturePin::PinCreate ( IN PKSPIN pKSPin,
- IN PIRP pIoRequestPacket
- )
-{
-
- NTSTATUS ntCreateStatus = STATUS_SUCCESS;
- PBDA_TRANSPORT_INFO pTransportInfo = NULL;
- CCapturePin *pCapturePin = new (NonPagedPool, CAPTURE_MEM_TAG) CCapturePin (pKSPin);
-
- PrintFunctionEntry(__FUNCTION__);
-
- if (!IS_VALID(pCapturePin))
- {
- //Return failure if we couldn't create the pin.
- ntCreateStatus = STATUS_INSUFFICIENT_RESOURCES;
-
- }
- else
- {
- //Add the item to the object bag if we we were successful.
- //Whenever the pin closes, the bag is cleaned up and we will be
- //freed.
-
- ntCreateStatus = KsAddItemToObjectBag (
- pKSPin->Bag,
- reinterpret_cast (pCapturePin),
- reinterpret_cast (CCapturePin::Cleanup)
- );
-
- if (!NT_SUCCESS (ntCreateStatus))
- {
- delete pCapturePin;
- }
- else
- {
- pKSPin->Context = reinterpret_cast (pCapturePin);
- }
-
- }
-
- //If we succeeded so far, stash the video info header away and change
- //our allocator framing to reflect the fact that only now do we know
- //the framing requirements based on the connection format.
- if (NT_SUCCESS (ntCreateStatus))
- {
-
- pTransportInfo = pCapturePin->CaptureBdaTransportInfo();
- if (!pTransportInfo)
- {
- ntCreateStatus = STATUS_INSUFFICIENT_RESOURCES;
- }
- }
-
- if (NT_SUCCESS (ntCreateStatus))
- {
- //We need to edit the descriptor to ensure we don't mess up any other
- //pins using the descriptor or touch read-only memory.
-
- ntCreateStatus = KsEdit (pKSPin, &pKSPin->Descriptor, CAPTURE_MEM_TAG);
-
- if (NT_SUCCESS (ntCreateStatus))
- {
- ntCreateStatus = KsEdit (
- pKSPin,
- &(pKSPin->Descriptor->AllocatorFraming),
- CAPTURE_MEM_TAG
- );
- }
-
- //If the edits proceeded without running out of memory, adjust
- //the framing based on the video info header.
- if (NT_SUCCESS (ntCreateStatus))
- {
-
- //We've KsEdit'ed this... I'm safe to cast away constness as
- //long as the edit succeeded.
- PKSALLOCATOR_FRAMING_EX pFraming =
- const_cast (
- pKSPin->Descriptor-> AllocatorFraming
- );
-
- pFraming->FramingItem[0].Frames = NUMBER_OF_FRAMES;
-
- //The physical and optimal ranges must be biSizeImage. We only
- //support one frame size, precisely the size of each capture
- //image.
- pFraming->FramingItem[0].PhysicalRange.MinFrameSize =
- pFraming->FramingItem[0].PhysicalRange.MaxFrameSize =
- pFraming->FramingItem[0].FramingRange.Range.MinFrameSize =
- pFraming->FramingItem[0].FramingRange.Range.MaxFrameSize =
- pTransportInfo->ulcbPhyiscalFrame;
-
- pFraming->FramingItem[0].PhysicalRange.Stepping =
- pFraming->FramingItem[0].FramingRange.Range.Stepping =
- 0;
-
- }
-
- }
-
- PrintFunctionExit(__FUNCTION__,ntCreateStatus);
- return ntCreateStatus;
-
-}
-
-/*****************************************************************************
- Function : CCapturePin::CaptureBdaTransportInfo
- Description : Capture the video info header out of the connection format.
- This is what we use to base synthesized images off.
- IN PARAM : NONE
- OUT PARAM : The captured video info header or
- NULL if there is insufficient memory.
- PreCondition : None
- PostCondtion : Create a new capture pin. This is the creation dispatch for
- the video capture pin.
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-PBDA_TRANSPORT_INFO CCapturePin::CaptureBdaTransportInfo()
-{
- PrintFunctionEntry(__FUNCTION__);
-
- m_TransportInfo = reinterpret_cast (
- ExAllocatePoolWithTag (
- NonPagedPool,
- sizeof(BDA_TRANSPORT_INFO),
- CAPTURE_MEM_TAG
- )
- );
-
- if (!IS_VALID(m_TransportInfo))
- {
- return NULL;
- }
-
- //Bag the newly allocated header space. This will get cleaned up
- //automatically when the pin closes.
- NTSTATUS Status =
- KsAddItemToObjectBag (
- m_Pin->Bag,
- reinterpret_cast (m_TransportInfo),
- NULL
- );
-
- if (!NT_SUCCESS (Status))
- {
- ExFreePoolWithTag (m_TransportInfo, CAPTURE_MEM_TAG);
- return NULL;
-
- }
- else
- {
- m_TransportInfo->ulcbPhyiscalPacket = TRANSPORT_PACKET_SIZE;
- m_TransportInfo->ulcbPhyiscalFrame = TRANSPORT_PACKET_SIZE * TRANSPORT_PACKET_COUNT;
- m_TransportInfo->ulcbPhyiscalFrameAlignment = 1;
- m_TransportInfo->AvgTimePerFrame = ((ULONGLONG)(19200)/* Maximum Sample Frequency */ *
- 10000 /* Maximum Bits Per second */ *
- NUMBER_OF_FRAMES) /*Maximum Channels */ /
- (TRANSPORT_PACKET_SIZE * TRANSPORT_PACKET_COUNT);
-
- }
-
- PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
- return m_TransportInfo;
-
-}
-
-/*****************************************************************************
- Function : CCapturePin::CleanupReferences
- Description : Clean up any references we're holding on frames after
- we abruptly stop the hardware.
- IN PARAM : NONE
- OUT PARAM : Success / Failure
- PreCondition : NONE
- PostCondtion : NONE
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CCapturePin::CleanupReferences ()
-{
- PKSSTREAM_POINTER pCloneStream = KsPinGetFirstCloneStreamPointer(m_Pin);
- PKSSTREAM_POINTER pNextCloneStream = NULL;
-
- PrintFunctionEntry(__FUNCTION__);
-
- //Walk through the clones, deleting them, and setting DataUsed to
- //zero since we didn't use any data!
- while (pCloneStream)
- {
-
- pNextCloneStream = KsStreamPointerGetNextClone(pCloneStream);
-
- pCloneStream->StreamHeader->DataUsed = 0;
- KsStreamPointerDelete (pCloneStream);
-
- pCloneStream = pNextCloneStream;
-
- }
-
- PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
- return STATUS_SUCCESS;
-}
-
-/*****************************************************************************
- Function : CCapturePin::SetState
- Description : This is called when the caputre pin transitions state.
- The routine attempts to acquire / release any hardware
- resources and start up or shut down capture based on
- the states we are transitioning to and away from.
- IN PARAM : ToState : The state we're transitioning to
- FromState : The state we're transitioning away from
- OUT PARAM : Success / Failure
- PreCondition : NONE
- PostCondtion : NONE
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CCapturePin::SetState (
- IN KSSTATE ToState,
- IN KSSTATE FromState
- )
-{
-
- NTSTATUS ntSetStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- PrintDeviceChangeState(ToState,FromState);
-
- switch (ToState)
- {
-
- case KSSTATE_STOP:
- //Stopping the Device Operation
- if (m_HardwareState != HardwareStopped)
- {
- ntSetStatus = m_Device->StopStream();
- m_HardwareState = HardwareStopped;
- }
-
-
- //The Device is Stopped
- //It has cancelled the IRPs and Stopped the Streaming
- //In case any Streaming Pointer is left Clean it up
- ntSetStatus = CleanupReferences();
-
- //Release any hardware resources related to this pin.
- if (m_AcquiredResources)
- {
- //Release the Clock Reference on the Pin
- if (m_Clock)
- {
- m_Clock->Release();
- m_Clock = NULL;
- }
-
- m_Device->RemoveCaptureSink();
- m_AcquiredResources = FALSE;
- }
- break;
-
- case KSSTATE_ACQUIRE:
-
- //Acquire Hardware resources here instead of Filter
- //Creation Time.So that the Filter creation does not
- //Fail because of Limited Hardware resources.
- if (FromState == KSSTATE_STOP)
- {
- ntSetStatus = m_Device->SetupCaptureSink(this,m_TransportInfo);
-
- if (NT_SUCCESS (ntSetStatus))
- {
- m_AcquiredResources = TRUE;
-
- //Attempt to get an interface to the master clock.
- //This will fail if one has not been assigned. Since
- //one must be assigned while the pin is still in
- //KSSTATE_STOP, this is a guranteed method of getting
- //the clock should one be assigned.
-
- if (!NT_SUCCESS (KsPinGetReferenceClockInterface(m_Pin,
- &m_Clock)))
- {
- //If we could not get an interface to the clock,
- //don't use one.
- SkyWalkerDebugPrint(ENTRY_LEVEL,("No Clock Assigned to the Pin\n"));
- m_Clock = NULL;
-
- }
-
- }
- else
- {
- m_AcquiredResources = FALSE;
- }
-
- }
- else
- {
- //
- //Standard transport pins will always receive transitions in
- //+/- 1 manner. This means we'll always see a PAUSE->ACQUIRE
- //transition before stopping the pin.
- //
- //The below is done because on DirectX 8.0, when the pin gets
- //a message to stop, the queue is inaccessible. The reset
- //which comes on every stop happens after this (at which time
- //the queue is inaccessible also). So, for compatibility with
- //DirectX 8.0, I am stopping the hardware at this
- //point and cleaning up all references we have on frames.See
- //the comments above regarding the CleanupReferences call.
-
- if (m_HardwareState != HardwareStopped)
- {
- ntSetStatus = m_Device->StopStream();
- m_HardwareState = HardwareStopped;
- }
-
- ntSetStatus = CleanupReferences ();
- }
-
- break;
-
- case KSSTATE_PAUSE:
-
- //Stop the Streaming if we're coming down from run.
- if (FromState == KSSTATE_RUN)
- {
-
- ntSetStatus = m_Device->PauseStream(TRUE);
-
- if (NT_SUCCESS (ntSetStatus))
- {
- m_HardwareState = HardwarePaused;
- }
-
- }
- break;
-
- case KSSTATE_RUN:
-
- //Start the Streaming or unpause it depending on
- //whether we're initially running or we've paused and restarted.
- if (m_HardwareState == HardwarePaused)
- {
- ntSetStatus = m_Device->PauseStream (FALSE);
- }
- else
- {
- ntSetStatus = m_Device->StartStream();
- }
-
- if (NT_SUCCESS (ntSetStatus))
- {
- m_HardwareState = HardwareRunning;
- }
-
- break;
-
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Completed the State Change\n"));
- PrintFunctionExit(__FUNCTION__,ntSetStatus);
- return ntSetStatus;
-
-}
-
-/*****************************************************************************
- Function : CCapturePin::Process
- Description : The process dispatch for the pin bridges to this location.
- We handle setting up scatter gather mappings, etc...
- IN PARAM : NONE
- OUT PARAM : Success / Failure
- PreCondition : NONE
- PostCondtion : NONE
- Logic : NONE
- Assumption : NONE
- Note : Future Approach for the Streaming Buffer
- 1) Create a Buffer of Size Stream->Data/m_SampleSize Here
- 2) Store the reference of the Newly Created Buffer into the
- Stream Context
- 3) Send the Buffer to the ReadStream(BufferPointer)
- 4) When CompleteMapping is returned Copy Data from Stream
- Context to Stream->Data
- Revision History:
- *****************************************************************************/
-NTSTATUS CCapturePin::Process()
-{
- NTSTATUS ntProcessStatus = STATUS_SUCCESS;
- PKSSTREAM_POINTER pLeadingStream = NULL;
- PKSSTREAM_POINTER pCloneStream = NULL;
- PSTREAM_POINTER_CONTEXT pStreamContext = NULL;
-
- PrintFunctionEntry(__FUNCTION__);
-
- pLeadingStream = KsPinGetLeadingEdgeStreamPointer (
- m_Pin,
- KSSTREAM_POINTER_STATE_LOCKED
- );
-
-
- if( !pLeadingStream )
- {
- //no system buffer available
- //This case can happen if it is the last pointer in the queue or
- //the system cannot give us the required buffer
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Warning: No system buffer available\n"));
- ntProcessStatus = STATUS_UNSUCCESSFUL;
- goto CompleteProcessing;
- }
- else
- {
-
- //First thing we need to do is clone the leading edge. This allows
- //us to keep reference on the frames while they're in DMA.
- ntProcessStatus = KsStreamPointerClone (
- pLeadingStream,
- NULL,
- sizeof (STREAM_POINTER_CONTEXT),
- &pCloneStream
- );
-
- if( !NT_SUCCESS(ntProcessStatus) )
- {
- //No System Buffer Available
- SkyWalkerDebugPrint(ENTRY_LEVEL,
- ("Error: Streampointer cloning unsuccessful\n"));
- ntProcessStatus = STATUS_UNSUCCESSFUL;
- goto CompleteProcessing;
- }
-
- //Is the buffer size correct
- if( pCloneStream->StreamHeader->FrameExtent <
- (static_cast (m_TransportInfo->ulcbPhyiscalFrame)) )
- {
- //Buffer size incorrect
- KsStreamPointerDelete(pCloneStream); //void function
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Error: Buffer size Incorrect\n"));
- ntProcessStatus = STATUS_UNSUCCESSFUL;
- goto CompleteProcessing;
- }
-
- //Set the stream header data used to 0. We update this
- //in the USB Data Read completions.
- pCloneStream->StreamHeader->DataUsed = 0;
-
- pStreamContext = reinterpret_cast
- (pCloneStream->Context);
-
- //Set the Stream Index
- pStreamContext->ulFrameIndex = m_CurrentFrameIndex;
-
- PrintStream(pLeadingStream);
-
- //(Refer NOTE above) Create a Stream Buffer Here and Submit
- //it for the Reading / DMA
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Current Stream Index = %lu",m_CurrentFrameIndex));
- m_Device->ReadStream(m_CurrentFrameIndex);
- m_CurrentFrameIndex = (m_CurrentFrameIndex+1) % NUMBER_OF_FRAMES;
-
- //Advance Stream pointer to the next available data frame
- ntProcessStatus = KsStreamPointerAdvance(pLeadingStream);
-
- if( (ntProcessStatus != STATUS_DEVICE_NOT_READY) &&
- (ntProcessStatus != STATUS_SUCCESS) )
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,
- ("Error: Video Capture Streampointer Advacement Failed\n"));
- }
- }
-
-CompleteProcessing:
-
- PrintFunctionExit(__FUNCTION__,ntProcessStatus);
- return ntProcessStatus;
-}
-
-/*****************************************************************************
- Function : CCapturePin::ReleaseStream
- Description : Called to notify the pin that a given Stream is completed
- IN PARAM : The Stream Index
- OUT PARAM : NONE
- PreCondition : NONE
- PostCondtion : Stream data is filled from the Internal Stream Buffer
- Other Stream Parameters are set and Clone is Deleted
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-void CCapturePin::ReleaseStream(IN ULONG ulStreamIndex)
-{
-
- PrintFunctionEntry(__FUNCTION__);
-
- //Walk through the clones list and delete clones whose time has come.
- //The list is guaranteed to be kept in the order they were cloned.
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Completing Stream %lu\n",ulStreamIndex));
-
- PKSSTREAM_POINTER pCloneStream = KsPinGetFirstCloneStreamPointer (m_Pin);
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Clone Stream pointer = 0x%p\n",pCloneStream));
-
- if(pCloneStream)
- {
- //Copy the Stream data from the Corresponding Streaming Buffer
- RtlCopyMemory((PUCHAR)pCloneStream->StreamHeader->Data,
- m_Device->GetSynthBuffer(ulStreamIndex),
- m_TransportInfo->ulcbPhyiscalFrame);
-
- pCloneStream->StreamHeader->DataUsed = m_TransportInfo->ulcbPhyiscalFrame;
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pCloneStream->StreamHeader->DataUsed = "
- "%lu\n",
- pCloneStream->StreamHeader->DataUsed));
-
- pCloneStream->StreamHeader->Duration = m_TransportInfo->AvgTimePerFrame;
-
- pCloneStream->StreamHeader->PresentationTime.Numerator =
- pCloneStream->StreamHeader->PresentationTime.Denominator = 1;
-
- //If a clock has been assigned, timestamp the packets with the
- //time shown on the clock.
- if (m_Clock)
- {
-
- LONGLONG ClockTime = m_Clock->GetTime ();
- pCloneStream->StreamHeader->PresentationTime.Time = ClockTime;
- pCloneStream->StreamHeader->OptionsFlags =
- KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
- KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;
-
- }
- else
- {
-
- //If there is no clock, don't time stamp the packets.
- pCloneStream->StreamHeader->PresentationTime.Time = 0;
-
- }
-
- PrintStream(pCloneStream);
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Stream Processed thus deleting the Clone\n"));
- KsStreamPointerDelete (pCloneStream);
-
- }
-
- PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
-
-}
-
-VOID PrintStream(IN PKSSTREAM_POINTER pStreamPointer)
-{
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Context = 0x%p\n",pStreamPointer->Context));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Pin = 0x%p\n",pStreamPointer->Pin));
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader = 0x%p\n",pStreamPointer->StreamHeader));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->Size = %lu\n",pStreamPointer->StreamHeader->Size));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->TypeSpecificFlags = %lu\n",pStreamPointer->StreamHeader->TypeSpecificFlags));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->PresentationTime.Time= %l\n",pStreamPointer->StreamHeader->PresentationTime.Time));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->PresentationTime.Numerator= %lu\n",pStreamPointer->StreamHeader->PresentationTime.Numerator));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->PresentationTime.Denominator= %lu\n",pStreamPointer->StreamHeader->PresentationTime.Denominator));
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->Duration = %l\n",pStreamPointer->StreamHeader->Duration));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->FrameExtent = %lu\n",pStreamPointer->StreamHeader->FrameExtent));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->DataUsed = %lu\n",pStreamPointer->StreamHeader->DataUsed));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->Data = 0x%p\n",pStreamPointer->StreamHeader->Data));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->OptionsFlags = %lu\n",pStreamPointer->StreamHeader->OptionsFlags));
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset = 0x%p\n",pStreamPointer->Offset));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Data = 0x%p\n",pStreamPointer->Offset->Data));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Mappings = 0x%p\n",pStreamPointer->Offset->Mappings));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Count = %lu\n",pStreamPointer->Offset->Count));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Remaining = %lu\n",pStreamPointer->Offset->Remaining));
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Data = 0x%p\n",pStreamPointer->OffsetIn.Data));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Mappings = 0x%p\n",pStreamPointer->OffsetIn.Mappings));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Count = %lu\n",pStreamPointer->OffsetIn.Count));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Remaining = %lu\n",pStreamPointer->OffsetIn.Remaining));
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Data = 0x%p\n",pStreamPointer->OffsetOut.Data));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Mappings = 0x%p\n",pStreamPointer->OffsetOut.Mappings));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Count = %lu\n",pStreamPointer->OffsetOut.Count));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Remaining = %lu\n",pStreamPointer->OffsetOut.Remaining));
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1CapturePin.cpp
+ Author :
+ Date :
+ Purpose : This file contains header for the video capture pin on
+ the capture filter.
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+/* Include the Library and Other header file */
+
+#include "SkyWalker1Main.h" //Common For all the Definitions,
+ //Declarations and Library Routines
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+VOID PrintStream(IN PKSSTREAM_POINTER pStreamPointer);
+/* End of Function prototype definitions */
+
+
+/*****************************************************************************
+ Function : CCapturePin
+ Description : Constructor of the CCapturePin Class
+ IN PARAM : NONE
+ OUT PARAM : NONE
+ PreCondition : pKSPin Object is not created
+ PostCondtion : pKSPin Object is created and Initialzed on successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+CCapturePin::CCapturePin(IN PKSPIN pKSPin) :
+ m_Pin (pKSPin)
+{
+ PKSDEVICE pKSDevice = KsPinGetDevice (pKSPin);
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Set up our device pointer. This gives us access to "Hardware I/O"
+ //during the capture routines.
+ m_Device = reinterpret_cast (pKSDevice->Context);
+
+ PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
+}
+
+/*****************************************************************************
+ Function : CCapturePin
+ Description : Destructor of the CCapturePin Class
+ IN PARAM : NONE
+ OUT PARAM : NONE
+ PreCondition : pKSPin Object is created
+ PostCondtion : pKSPin Object is Removed and Memory freed
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+CCapturePin::~CCapturePin()
+{
+ PrintFunctionEntry(__FUNCTION__);
+ PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
+}
+
+/*****************************************************************************
+ Function : CCapturePin::PinCreate
+ Description : An AVStream minidriver's AVStrMiniPinCreate routine is
+ called when a pin is created. Typically, this routine is
+ used by minidrivers that want to initialize the context
+ and resources associated with the pin.
+ IN PARAM : Pointer to the KSPIN that was just created.
+ Pointer to the IRP_MJ_CREATE for pKSPin
+ OUT PARAM : STATUS_SUCCESS in case of successful pin creation
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Create a new capture pin. This is the creation dispatch for
+ the video capture pin.
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CCapturePin::PinCreate ( IN PKSPIN pKSPin,
+ IN PIRP pIoRequestPacket
+ )
+{
+
+ NTSTATUS ntCreateStatus = STATUS_SUCCESS;
+ PBDA_TRANSPORT_INFO pTransportInfo = NULL;
+ CCapturePin *pCapturePin = new (NonPagedPool, CAPTURE_MEM_TAG) CCapturePin (pKSPin);
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ if (!IS_VALID(pCapturePin))
+ {
+ //Return failure if we couldn't create the pin.
+ ntCreateStatus = STATUS_INSUFFICIENT_RESOURCES;
+
+ }
+ else
+ {
+ //Add the item to the object bag if we we were successful.
+ //Whenever the pin closes, the bag is cleaned up and we will be
+ //freed.
+
+ ntCreateStatus = KsAddItemToObjectBag (
+ pKSPin->Bag,
+ reinterpret_cast (pCapturePin),
+ reinterpret_cast (CCapturePin::Cleanup)
+ );
+
+ if (!NT_SUCCESS (ntCreateStatus))
+ {
+ delete pCapturePin;
+ }
+ else
+ {
+ pKSPin->Context = reinterpret_cast (pCapturePin);
+ }
+
+ }
+
+ //If we succeeded so far, stash the video info header away and change
+ //our allocator framing to reflect the fact that only now do we know
+ //the framing requirements based on the connection format.
+ if (NT_SUCCESS (ntCreateStatus))
+ {
+
+ pTransportInfo = pCapturePin->CaptureBdaTransportInfo();
+ if (!pTransportInfo)
+ {
+ ntCreateStatus = STATUS_INSUFFICIENT_RESOURCES;
+ }
+ }
+
+ if (NT_SUCCESS (ntCreateStatus))
+ {
+ //We need to edit the descriptor to ensure we don't mess up any other
+ //pins using the descriptor or touch read-only memory.
+
+ ntCreateStatus = KsEdit (pKSPin, &pKSPin->Descriptor, CAPTURE_MEM_TAG);
+
+ if (NT_SUCCESS (ntCreateStatus))
+ {
+ ntCreateStatus = KsEdit (
+ pKSPin,
+ &(pKSPin->Descriptor->AllocatorFraming),
+ CAPTURE_MEM_TAG
+ );
+ }
+
+ //If the edits proceeded without running out of memory, adjust
+ //the framing based on the video info header.
+ if (NT_SUCCESS (ntCreateStatus))
+ {
+
+ //We've KsEdit'ed this... I'm safe to cast away constness as
+ //long as the edit succeeded.
+ PKSALLOCATOR_FRAMING_EX pFraming =
+ const_cast (
+ pKSPin->Descriptor-> AllocatorFraming
+ );
+
+ pFraming->FramingItem[0].Frames = NUMBER_OF_FRAMES;
+
+ //The physical and optimal ranges must be biSizeImage. We only
+ //support one frame size, precisely the size of each capture
+ //image.
+ pFraming->FramingItem[0].PhysicalRange.MinFrameSize =
+ pFraming->FramingItem[0].PhysicalRange.MaxFrameSize =
+ pFraming->FramingItem[0].FramingRange.Range.MinFrameSize =
+ pFraming->FramingItem[0].FramingRange.Range.MaxFrameSize =
+ pTransportInfo->ulcbPhyiscalFrame;
+
+ pFraming->FramingItem[0].PhysicalRange.Stepping =
+ pFraming->FramingItem[0].FramingRange.Range.Stepping =
+ 0;
+
+ }
+
+ }
+
+ PrintFunctionExit(__FUNCTION__,ntCreateStatus);
+ return ntCreateStatus;
+
+}
+
+/*****************************************************************************
+ Function : CCapturePin::CaptureBdaTransportInfo
+ Description : Capture the video info header out of the connection format.
+ This is what we use to base synthesized images off.
+ IN PARAM : NONE
+ OUT PARAM : The captured video info header or
+ NULL if there is insufficient memory.
+ PreCondition : None
+ PostCondtion : Create a new capture pin. This is the creation dispatch for
+ the video capture pin.
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+PBDA_TRANSPORT_INFO CCapturePin::CaptureBdaTransportInfo()
+{
+ PrintFunctionEntry(__FUNCTION__);
+
+ m_TransportInfo = reinterpret_cast (
+ ExAllocatePoolWithTag (
+ NonPagedPool,
+ sizeof(BDA_TRANSPORT_INFO),
+ CAPTURE_MEM_TAG
+ )
+ );
+
+ if (!IS_VALID(m_TransportInfo))
+ {
+ return NULL;
+ }
+
+ //Bag the newly allocated header space. This will get cleaned up
+ //automatically when the pin closes.
+ NTSTATUS Status =
+ KsAddItemToObjectBag (
+ m_Pin->Bag,
+ reinterpret_cast (m_TransportInfo),
+ NULL
+ );
+
+ if (!NT_SUCCESS (Status))
+ {
+ ExFreePoolWithTag (m_TransportInfo, CAPTURE_MEM_TAG);
+ return NULL;
+
+ }
+ else
+ {
+ m_TransportInfo->ulcbPhyiscalPacket = TRANSPORT_PACKET_SIZE;
+ m_TransportInfo->ulcbPhyiscalFrame = TRANSPORT_PACKET_SIZE * TRANSPORT_PACKET_COUNT;
+ m_TransportInfo->ulcbPhyiscalFrameAlignment = 1;
+ m_TransportInfo->AvgTimePerFrame = ((ULONGLONG)(19200)/* Maximum Sample Frequency */ *
+ 10000 /* Maximum Bits Per second */ *
+ NUMBER_OF_FRAMES) /*Maximum Channels */ /
+ (TRANSPORT_PACKET_SIZE * TRANSPORT_PACKET_COUNT);
+
+ }
+
+ PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
+ return m_TransportInfo;
+
+}
+
+/*****************************************************************************
+ Function : CCapturePin::CleanupReferences
+ Description : Clean up any references we're holding on frames after
+ we abruptly stop the hardware.
+ IN PARAM : NONE
+ OUT PARAM : Success / Failure
+ PreCondition : NONE
+ PostCondtion : NONE
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CCapturePin::CleanupReferences ()
+{
+ PKSSTREAM_POINTER pCloneStream = KsPinGetFirstCloneStreamPointer(m_Pin);
+ PKSSTREAM_POINTER pNextCloneStream = NULL;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Walk through the clones, deleting them, and setting DataUsed to
+ //zero since we didn't use any data!
+ while (pCloneStream)
+ {
+
+ pNextCloneStream = KsStreamPointerGetNextClone(pCloneStream);
+
+ pCloneStream->StreamHeader->DataUsed = 0;
+ KsStreamPointerDelete (pCloneStream);
+
+ pCloneStream = pNextCloneStream;
+
+ }
+
+ PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
+ return STATUS_SUCCESS;
+}
+
+/*****************************************************************************
+ Function : CCapturePin::SetState
+ Description : This is called when the caputre pin transitions state.
+ The routine attempts to acquire / release any hardware
+ resources and start up or shut down capture based on
+ the states we are transitioning to and away from.
+ IN PARAM : ToState : The state we're transitioning to
+ FromState : The state we're transitioning away from
+ OUT PARAM : Success / Failure
+ PreCondition : NONE
+ PostCondtion : NONE
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CCapturePin::SetState (
+ IN KSSTATE ToState,
+ IN KSSTATE FromState
+ )
+{
+
+ NTSTATUS ntSetStatus = STATUS_SUCCESS;
+ PrintFunctionEntry(__FUNCTION__);
+
+ PrintDeviceChangeState(ToState,FromState);
+
+ switch (ToState)
+ {
+
+ case KSSTATE_STOP:
+ //Stopping the Device Operation
+ if (m_HardwareState != HardwareStopped)
+ {
+ ntSetStatus = m_Device->StopStream();
+ m_HardwareState = HardwareStopped;
+ }
+
+
+ //The Device is Stopped
+ //It has cancelled the IRPs and Stopped the Streaming
+ //In case any Streaming Pointer is left Clean it up
+ ntSetStatus = CleanupReferences();
+
+ //Release any hardware resources related to this pin.
+ if (m_AcquiredResources)
+ {
+ //Release the Clock Reference on the Pin
+ if (m_Clock)
+ {
+ m_Clock->Release();
+ m_Clock = NULL;
+ }
+
+ m_Device->RemoveCaptureSink();
+ m_AcquiredResources = FALSE;
+ }
+ break;
+
+ case KSSTATE_ACQUIRE:
+
+ //Acquire Hardware resources here instead of Filter
+ //Creation Time.So that the Filter creation does not
+ //Fail because of Limited Hardware resources.
+ if (FromState == KSSTATE_STOP)
+ {
+ ntSetStatus = m_Device->SetupCaptureSink(this,m_TransportInfo);
+
+ if (NT_SUCCESS (ntSetStatus))
+ {
+ m_AcquiredResources = TRUE;
+
+ //Attempt to get an interface to the master clock.
+ //This will fail if one has not been assigned. Since
+ //one must be assigned while the pin is still in
+ //KSSTATE_STOP, this is a guranteed method of getting
+ //the clock should one be assigned.
+
+ if (!NT_SUCCESS (KsPinGetReferenceClockInterface(m_Pin,
+ &m_Clock)))
+ {
+ //If we could not get an interface to the clock,
+ //don't use one.
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("No Clock Assigned to the Pin\n"));
+ m_Clock = NULL;
+
+ }
+
+ }
+ else
+ {
+ m_AcquiredResources = FALSE;
+ }
+
+ }
+ else
+ {
+ //
+ //Standard transport pins will always receive transitions in
+ //+/- 1 manner. This means we'll always see a PAUSE->ACQUIRE
+ //transition before stopping the pin.
+ //
+ //The below is done because on DirectX 8.0, when the pin gets
+ //a message to stop, the queue is inaccessible. The reset
+ //which comes on every stop happens after this (at which time
+ //the queue is inaccessible also). So, for compatibility with
+ //DirectX 8.0, I am stopping the hardware at this
+ //point and cleaning up all references we have on frames.See
+ //the comments above regarding the CleanupReferences call.
+
+ if (m_HardwareState != HardwareStopped)
+ {
+ ntSetStatus = m_Device->StopStream();
+ m_HardwareState = HardwareStopped;
+ }
+
+ ntSetStatus = CleanupReferences ();
+ }
+
+ break;
+
+ case KSSTATE_PAUSE:
+
+ //Stop the Streaming if we're coming down from run.
+ if (FromState == KSSTATE_RUN)
+ {
+
+ ntSetStatus = m_Device->PauseStream(TRUE);
+
+ if (NT_SUCCESS (ntSetStatus))
+ {
+ m_HardwareState = HardwarePaused;
+ }
+
+ }
+ break;
+
+ case KSSTATE_RUN:
+
+ //Start the Streaming or unpause it depending on
+ //whether we're initially running or we've paused and restarted.
+ if (m_HardwareState == HardwarePaused)
+ {
+ ntSetStatus = m_Device->PauseStream (FALSE);
+ }
+ else
+ {
+ ntSetStatus = m_Device->StartStream();
+ }
+
+ if (NT_SUCCESS (ntSetStatus))
+ {
+ m_HardwareState = HardwareRunning;
+ }
+
+ break;
+
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Completed the State Change\n"));
+ PrintFunctionExit(__FUNCTION__,ntSetStatus);
+ return ntSetStatus;
+
+}
+
+/*****************************************************************************
+ Function : CCapturePin::Process
+ Description : The process dispatch for the pin bridges to this location.
+ We handle setting up scatter gather mappings, etc...
+ IN PARAM : NONE
+ OUT PARAM : Success / Failure
+ PreCondition : NONE
+ PostCondtion : NONE
+ Logic : NONE
+ Assumption : NONE
+ Note : Future Approach for the Streaming Buffer
+ 1) Create a Buffer of Size Stream->Data/m_SampleSize Here
+ 2) Store the reference of the Newly Created Buffer into the
+ Stream Context
+ 3) Send the Buffer to the ReadStream(BufferPointer)
+ 4) When CompleteMapping is returned Copy Data from Stream
+ Context to Stream->Data
+ Revision History:
+ *****************************************************************************/
+NTSTATUS CCapturePin::Process()
+{
+ NTSTATUS ntProcessStatus = STATUS_SUCCESS;
+ PKSSTREAM_POINTER pLeadingStream = NULL;
+ PKSSTREAM_POINTER pCloneStream = NULL;
+ PSTREAM_POINTER_CONTEXT pStreamContext = NULL;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ pLeadingStream = KsPinGetLeadingEdgeStreamPointer (
+ m_Pin,
+ KSSTREAM_POINTER_STATE_LOCKED
+ );
+
+
+ if( !pLeadingStream )
+ {
+ //no system buffer available
+ //This case can happen if it is the last pointer in the queue or
+ //the system cannot give us the required buffer
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Warning: No system buffer available\n"));
+ ntProcessStatus = STATUS_UNSUCCESSFUL;
+ goto CompleteProcessing;
+ }
+ else
+ {
+
+ //First thing we need to do is clone the leading edge. This allows
+ //us to keep reference on the frames while they're in DMA.
+ ntProcessStatus = KsStreamPointerClone (
+ pLeadingStream,
+ NULL,
+ sizeof (STREAM_POINTER_CONTEXT),
+ &pCloneStream
+ );
+
+ if( !NT_SUCCESS(ntProcessStatus) )
+ {
+ //No System Buffer Available
+ SkyWalkerDebugPrint(ENTRY_LEVEL,
+ ("Error: Streampointer cloning unsuccessful\n"));
+ ntProcessStatus = STATUS_UNSUCCESSFUL;
+ goto CompleteProcessing;
+ }
+
+ //Is the buffer size correct
+ if( pCloneStream->StreamHeader->FrameExtent <
+ (static_cast (m_TransportInfo->ulcbPhyiscalFrame)) )
+ {
+ //Buffer size incorrect
+ KsStreamPointerDelete(pCloneStream); //void function
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Error: Buffer size Incorrect\n"));
+ ntProcessStatus = STATUS_UNSUCCESSFUL;
+ goto CompleteProcessing;
+ }
+
+ //Set the stream header data used to 0. We update this
+ //in the USB Data Read completions.
+ pCloneStream->StreamHeader->DataUsed = 0;
+
+ pStreamContext = reinterpret_cast
+ (pCloneStream->Context);
+
+ //Set the Stream Index
+ pStreamContext->ulFrameIndex = m_CurrentFrameIndex;
+
+ PrintStream(pLeadingStream);
+
+ //(Refer NOTE above) Create a Stream Buffer Here and Submit
+ //it for the Reading / DMA
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Current Stream Index = %lu",m_CurrentFrameIndex));
+ m_Device->ReadStream(m_CurrentFrameIndex);
+ m_CurrentFrameIndex = (m_CurrentFrameIndex+1) % NUMBER_OF_FRAMES;
+
+ //Advance Stream pointer to the next available data frame
+ ntProcessStatus = KsStreamPointerAdvance(pLeadingStream);
+
+ if( (ntProcessStatus != STATUS_DEVICE_NOT_READY) &&
+ (ntProcessStatus != STATUS_SUCCESS) )
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,
+ ("Error: Video Capture Streampointer Advacement Failed\n"));
+ }
+ }
+
+CompleteProcessing:
+
+ PrintFunctionExit(__FUNCTION__,ntProcessStatus);
+ return ntProcessStatus;
+}
+
+/*****************************************************************************
+ Function : CCapturePin::ReleaseStream
+ Description : Called to notify the pin that a given Stream is completed
+ IN PARAM : The Stream Index
+ OUT PARAM : NONE
+ PreCondition : NONE
+ PostCondtion : Stream data is filled from the Internal Stream Buffer
+ Other Stream Parameters are set and Clone is Deleted
+ Logic : NONE
+ Assumption : NONE
+ Note : NONE
+ Revision History:
+ *****************************************************************************/
+void CCapturePin::ReleaseStream(IN ULONG ulStreamIndex)
+{
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Walk through the clones list and delete clones whose time has come.
+ //The list is guaranteed to be kept in the order they were cloned.
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Completing Stream %lu\n",ulStreamIndex));
+
+ PKSSTREAM_POINTER pCloneStream = KsPinGetFirstCloneStreamPointer (m_Pin);
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Clone Stream pointer = 0x%p\n",pCloneStream));
+
+ if(pCloneStream)
+ {
+ //Copy the Stream data from the Corresponding Streaming Buffer
+ RtlCopyMemory((PUCHAR)pCloneStream->StreamHeader->Data,
+ m_Device->GetSynthBuffer(ulStreamIndex),
+ m_TransportInfo->ulcbPhyiscalFrame);
+
+ pCloneStream->StreamHeader->DataUsed = m_TransportInfo->ulcbPhyiscalFrame;
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pCloneStream->StreamHeader->DataUsed = "
+ "%lu\n",
+ pCloneStream->StreamHeader->DataUsed));
+
+ pCloneStream->StreamHeader->Duration = m_TransportInfo->AvgTimePerFrame;
+
+ pCloneStream->StreamHeader->PresentationTime.Numerator =
+ pCloneStream->StreamHeader->PresentationTime.Denominator = 1;
+
+ //If a clock has been assigned, timestamp the packets with the
+ //time shown on the clock.
+ if (m_Clock)
+ {
+
+ LONGLONG ClockTime = m_Clock->GetTime ();
+ pCloneStream->StreamHeader->PresentationTime.Time = ClockTime;
+ pCloneStream->StreamHeader->OptionsFlags =
+ KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
+ KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;
+
+ }
+ else
+ {
+
+ //If there is no clock, don't time stamp the packets.
+ pCloneStream->StreamHeader->PresentationTime.Time = 0;
+
+ }
+
+ PrintStream(pCloneStream);
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Stream Processed thus deleting the Clone\n"));
+ KsStreamPointerDelete (pCloneStream);
+
+ }
+
+ PrintFunctionExit(__FUNCTION__,STATUS_SUCCESS);
+
+}
+
+VOID PrintStream(IN PKSSTREAM_POINTER pStreamPointer)
+{
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Context = 0x%p\n",pStreamPointer->Context));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Pin = 0x%p\n",pStreamPointer->Pin));
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader = 0x%p\n",pStreamPointer->StreamHeader));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->Size = %lu\n",pStreamPointer->StreamHeader->Size));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->TypeSpecificFlags = %lu\n",pStreamPointer->StreamHeader->TypeSpecificFlags));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->PresentationTime.Time= %l\n",pStreamPointer->StreamHeader->PresentationTime.Time));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->PresentationTime.Numerator= %lu\n",pStreamPointer->StreamHeader->PresentationTime.Numerator));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->PresentationTime.Denominator= %lu\n",pStreamPointer->StreamHeader->PresentationTime.Denominator));
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->Duration = %l\n",pStreamPointer->StreamHeader->Duration));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->FrameExtent = %lu\n",pStreamPointer->StreamHeader->FrameExtent));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->DataUsed = %lu\n",pStreamPointer->StreamHeader->DataUsed));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->Data = 0x%p\n",pStreamPointer->StreamHeader->Data));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->StreamHeader->OptionsFlags = %lu\n",pStreamPointer->StreamHeader->OptionsFlags));
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset = 0x%p\n",pStreamPointer->Offset));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Data = 0x%p\n",pStreamPointer->Offset->Data));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Mappings = 0x%p\n",pStreamPointer->Offset->Mappings));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Count = %lu\n",pStreamPointer->Offset->Count));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->Offset->Remaining = %lu\n",pStreamPointer->Offset->Remaining));
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Data = 0x%p\n",pStreamPointer->OffsetIn.Data));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Mappings = 0x%p\n",pStreamPointer->OffsetIn.Mappings));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Count = %lu\n",pStreamPointer->OffsetIn.Count));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetIn.Remaining = %lu\n",pStreamPointer->OffsetIn.Remaining));
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Data = 0x%p\n",pStreamPointer->OffsetOut.Data));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Mappings = 0x%p\n",pStreamPointer->OffsetOut.Mappings));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Count = %lu\n",pStreamPointer->OffsetOut.Count));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pStreamPointer->OffsetOut.Remaining = %lu\n",pStreamPointer->OffsetOut.Remaining));
}
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Control.cpp b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Control.cpp
index 0f698d2..1cd0f20 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Control.cpp
+++ b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Control.cpp
@@ -1,704 +1,704 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Control.cpp
- Author :
- Date :
- Purpose : This File Holds the Device Control related declarations
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- XXth April,2009 01 Initial Version
-
-*****************************************************************************/
-/* Include the Library and Other header file */
-
-#include "SkyWalker1Main.h" //Common For all the Definitions,
- //Declarations and Library Routines
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-VOID PrintDiseqcCommand(PDISEQC_COMMAND pDiseqcCommand);
-/* End of Function prototype definitions */
-
-/*****************************************************************************
- Function : GetSignalStatus
- Description : This Function Get the Signal Lock Status
- IN PARAM : Pointer to the KSDevice Object
- true in case of Signal Locked else False
- OUT PARAM : STATUS_SUCCESS in case of successful Lock Read
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Gets the Signal Lock Status in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS GetSignalStatus( IN PKSDEVICE pKSDeviceObject,
- OUT PBOOLEAN pbSignalLockStatus
- )
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- UCHAR ucSignalStatus = 0;
-
- PrintFunctionEntry(__FUNCTION__);
-
- //gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0, 0, &lock,1)
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- GET_SIGNAL_LOCK,
- 0,
- 0,
- &ucSignalStatus,
- 1,
- true);
- if(NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(EXTREME_LEVEL,("ucSignalStatus = 0x%02X\n",ucSignalStatus));
-
- if(ucSignalStatus)
- {
- *pbSignalLockStatus = TRUE;
- }
- else
- {
- *pbSignalLockStatus = FALSE;
- }
- }
-
- //if (lock)
- // *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER;
- //else
- // *status = 0;
-
- if(ucSignalStatus)
- {
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Signal Lock = 0x%02X\n",*pbSignalLockStatus));
- }
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-
-}
-
-/*****************************************************************************
- Function : ReadTunerSignalStrength
- Description : This Function reads the Tuner Signal Strength
- IN PARAM : Pointer to the KSDevice Object
- Pointer to hold the Signal Strength
- OUT PARAM : STATUS_SUCCESS in case of successful read
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Reads the Signal Strength
- Logic : NONE
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS ReadTunerSignalStrength( IN PKSDEVICE pKSDeviceObject,
- OUT PULONG pulSigStrength
- )
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- UCHAR ucBuffer[6] = {0,0,0,0,0,0};
- ULONG ulSignalStrength = 0L;
-
- PrintFunctionEntry(__FUNCTION__);
-
- //gp8psk_usb_in_op(st->d, GET_SIGNAL_STRENGTH, 0,0,buf,6);
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- GET_SIGNAL_STRENGTH,
- 0,
- 0,
- ucBuffer,
- 6,
- true);
- if(NT_SUCCESS(ntStatus))
- {
- ulSignalStrength = (int)(ucBuffer[1]) << 8 | ucBuffer[0];
- SkyWalkerDebugPrint(EXTREME_LEVEL,("ulSignalStrength = %lu,ucBuffer[1] = 0x%02X, ucBuffer[2] = 0x%02X\n",
- ulSignalStrength,ucBuffer[1],ucBuffer[0]));
- //*pulSigStrength = (int)(ucBuffer[1]) << 8 | ucBuffer[0];
- /* snr is reported in dBu*256 */
- /* snr / 38.4 ~= 100% strength */
- /* snr * 17 returns 100% strength as 65535 */
- if (ulSignalStrength <= 0x0F00)
- {
- *pulSigStrength = (ulSignalStrength <<4) + ulSignalStrength;
- }
- else
- {
- *pulSigStrength = 0xFFFF;
- }
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Signal Strength = %lu\n",*pulSigStrength));
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-
-}
-
-/*****************************************************************************
- Function : SetLnbVoltage
- Description : This Function Sets the LNB Voltage
- IN PARAM : Pointer to the KSDevice Object
- Voltage to set 1 for 18V and 0 for 13V
- OUT PARAM : STATUS_SUCCESS in case of successful Set
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Sets the LNB Voltage in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS SetLnbVoltage(IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucVoltage)
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("New Lnb Voltage (0 = 13V, 1 = 18V) = %02d \n",ucVoltage));
-
- //gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE,
- // voltage == SEC_VOLTAGE_18, 0, NULL, 0)
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- SET_LNB_VOLTAGE,
- (ucVoltage == SEC_VOLTAGE_18),
- 0,
- NULL,
- 0,
- false);
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-
-
-}
-
-
-/*****************************************************************************
- Function : TuneDevice
- Description : This Function Tunes the Tuner
- IN PARAM : Pointer to the KSDevice Object
- Tuner parameters to set
- OUT PARAM : STATUS_SUCCESS in case of successful Set
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Tuners the Tuner in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : To tune the Tuner following command needs to be sent
- 9 8 7 6 5 4 3 2 1 0
-=================================================================================
-| FECR | MOD | TFQ0 | TFQ0 | TFQ0 | TFQ0 | SBR3 | SBR2 | SBR1 | SBR0 |
-=================================================================================
-Where FECR -> Inner FEC Rate (1 Byte)
-MOD = Modulation = QPSK (1 Byte)
-TF = Tuner Frequency (4 Bytes)
-SBR = Symbol Rate (4 Bytes)
-
- Revision History:
- *****************************************************************************/
-NTSTATUS TuneDevice(IN PKSDEVICE pKSDeviceObject,
- IN PBDATUNER_DEVICE_PARAMETER pDeviceParameter)
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- UCHAR ucCommand[10];
- ULONG ulTempFrequency = 0L;
- ULONG ulTunerFrequency = 0L;
- ULONG ulLOFrequency = 0L;
- ULONG ulTempSymbolRate = 0L;
-
- PrintFunctionEntry(__FUNCTION__);
-
- //Setting the Local Oscillator Frequency
- if(pDeviceParameter->ulLnbSwitchFrequency >= pDeviceParameter->ulCarrierFrequency)
- {
- ulLOFrequency = pDeviceParameter->ulLnbLowLOFrequency;
- }
- else
- {
- ulLOFrequency = pDeviceParameter->ulLnbHighLOFrequency;
- }
-
- //Getting the Frequency to be tuned based on the Carrier frequency and
- //Local Oscillator frequency (LOF)
- if(pDeviceParameter->ulCarrierFrequency > ulLOFrequency)
- {
- ulTempFrequency = pDeviceParameter->ulCarrierFrequency - ulLOFrequency;
- }
- else
- {
- ulTempFrequency = ulLOFrequency - pDeviceParameter->ulCarrierFrequency;
- }
-
- if( (ulTempFrequency < TUNER_FREQ_MIN) ||
- (ulTempFrequency > TUNER_FREQ_MAX))
- {
- SkyWalkerDebugPrint(EXTREME_LEVEL,
- ("Frequency Out of Bound %lu, Resetting to %lu\n",
- ulTempFrequency,TUNER_FREQ_MIN));
- ulTempFrequency = TUNER_FREQ_MIN;
- }
- ulTunerFrequency= ulTempFrequency * pDeviceParameter->ulFrequencyMultiplier;
-
- //Symbol Rate should be in Sample Per Second thus converting the
- //Kilo Samples per Second (ksps) to Samples Per Second (sps)
- ulTempSymbolRate = pDeviceParameter->ulSymbolRate * 1000;
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("New Symbol Rate = %lu sps (%lu ksps)\n"
- "Carrier Frequency = %lu\n"
- "Local Oscillator Freq = %lu\n"
- "Frequency Multiplier = %lu\n"
- "Tuner Frequency = %lu\n"
- "New Modulation Type (QPSK = 0)= %lu\n"
- "New FEC Rate (VITERBI = 1)= %lu \n",
- ulTempSymbolRate,
- pDeviceParameter->ulSymbolRate,
- pDeviceParameter->ulCarrierFrequency,
- ulLOFrequency,
- pDeviceParameter->ulFrequencyMultiplier,
- ulTunerFrequency,
- ADV_MOD_DVB_QPSK,
- pDeviceParameter->InnerFecRate));
-
- ucCommand[0] = (UCHAR)(ulTempSymbolRate & 0xFF);
- ucCommand[1] = (UCHAR)((ulTempSymbolRate >> 8) & 0xFF);
- ucCommand[2] = (UCHAR)((ulTempSymbolRate >> 16) & 0xFF);
- ucCommand[3] = (UCHAR)((ulTempSymbolRate >> 24) & 0xFF);
-
- ucCommand[4] = (UCHAR)(ulTunerFrequency & 0xFF);
- ucCommand[5] = (UCHAR)((ulTunerFrequency >> 8) & 0xFF);
- ucCommand[6] = (UCHAR)((ulTunerFrequency >> 16) & 0xFF);
- ucCommand[7] = (UCHAR)((ulTunerFrequency >> 24) & 0xFF);
-
- ucCommand[8] = ADV_MOD_DVB_QPSK;
- ucCommand[9] = 0x05;
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Tune Command : Symbol Rate = 0x%02X%02X%02X%02X,"
- "Frequency = 0x%02X%02X%02X%02X",
- ucCommand[3],ucCommand[2],ucCommand[1],ucCommand[0],
- ucCommand[7],ucCommand[6],ucCommand[5],ucCommand[4]));
-
- //gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10);
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- TUNE_8PSK,
- 0,
- 0,
- ucCommand,
- 10,
- false);
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-}
-
-/*****************************************************************************
- Function : SetupTunerPower
- Description : Function to used to Setup the SkyWalker1 Device Power
- IN PARAM : Pointer to Device Object which needs Power setup
- Switch on / Switch Off
- OUT PARAM : ntStatus of the SkyWalker1 Power Setup
- STATUS_SUCCESS on Successful execution
- else Error from the Bus Driver
- PreCondition : NONE
- PostCondtion : On Success Device ready for the Operation
- Logic : Linux Method to Setup the Device
- 1) Download Firmware (Not done here)
- 2) Set Power State to ON
- 3) Read 8PSK Config ntStatus
- 4) if(Device not Started) then Start it
- 5) if(BCM4500 Firmware not loaded) then load it
- 6) if (LNB Power not set) then Set it
- 7) Set DVB_MODE to 1
- 8) Read Again the 8PSK Config ntStatus
- Assumption : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS SetupTunerPower( IN PKSDEVICE pKSDeviceObject,
- IN BOOLEAN bOnOff)
-{
-
- NTSTATUS ntStatus = STATUS_SUCCESS;
- UCHAR ucDeviceConfig = 0;
- UCHAR ucBuffer = 0;
-
- PrintFunctionEntry(__FUNCTION__);
-
- if (bOnOff)
- {
- //If Tuner Power On
-
- //Read the Tuner Configuration First
- //gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1);
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- GET_8PSK_CONFIG,
- 0,
- 0,
- &ucDeviceConfig,
- 1,
- true);
-
- if(!NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Read the Device Configuration\n"));
- goto ExitSetupPower;
-
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,
- ("Device Status Bit0:Device Start,Bit1:Firmware Loaded," \
- "Bit2:LNB Powerup = 0x%02X\n",
- ucDeviceConfig));
-
- if (!(ucDeviceConfig & bm8pskStarted)) /* Device Start ntStatus BIT-0 */
- {
- //Device Not Started
- //Send the Boot Command to the Device
- //gp8psk_usb_in_op(d, BOOT_8PSK, 1, 0, &buf, 1))
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- BOOT_8PSK,
- 1,
- 0,
- &ucBuffer,
- 1,
- true);
- if(!NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Boot the Device\n"));
- goto ExitSetupPower;
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Boot Response 0x%02X\n",ucBuffer));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Device Bootedup\n"));
-
- }
-
- if (!(ucDeviceConfig & bm8pskFW_Loaded)) /* Firmware ntStatus BIT-1 */
- {
- //Firmware Not Loaded
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Firmware not Loaded\n"));
- }
-
- if (!(ucDeviceConfig & bmIntersilOn)) /* LNB Power Status BIT-2 */
- {
- //LNB Not powered On
- //Sent the Power On Command to the LNB
- ucBuffer = 0;
- //gp8psk_usb_in_op(d, START_INTERSIL, 1, 0,&buf, 1))
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- START_INTERSIL,
- 1,
- 0,
- &ucBuffer,
- 1,
- true);
- if(!NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Powerup the Device\n"));
- goto ExitSetupPower;
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("LNB Powerup Response 0x%02X\n",ucBuffer));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Device Poweredup\n"));
-
- }
-
- /* Abort possible TS (if previous tune crashed) */
- //gp8psk_usb_out_op(d, ARM_TRANSFER, 0, 0, NULL, 0)
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- ARM_TRANSFER,
- 0,
- 0,
- NULL,
- 0,
- false);
-
- //Reread the Device Configuration
- //gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1);
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- GET_8PSK_CONFIG,
- 0,
- 0,
- &ucDeviceConfig,
- 1,
- true);
-
- if(!NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Read the Device Configuration\n"));
- goto ExitSetupPower;
-
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,
- ("Device ntStatus Bit0:Device Start,Bit1:Firmware Loaded," \
- "Bit2:LNB Powerup = 0x%02X\n",
- ucDeviceConfig));
-
-
- }
- else
- {
- //Turn Off LNB Power
- //gp8psk_usb_in_op(d, START_INTERSIL, 0, 0, &buf, 1)
- ucBuffer = 0;
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- START_INTERSIL,
- 0,
- 0,
- &ucBuffer,
- 1,
- true);
- if(!NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Powerdown the LNB\n"));
- goto ExitSetupPower;
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("LNB Powerdown Response 0x%02X\n",ucBuffer));
-
- //Turn Off 8PSK Power
- //gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1)
- ucBuffer = 0;
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- BOOT_8PSK,
- 0,
- 0,
- &ucBuffer,
- 1,
- true);
- if(!NT_SUCCESS(ntStatus))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Powerdown the SkyWalker1\n"));
- goto ExitSetupPower;
- }
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Tuner Powerdown Response 0x%02X\n",ucBuffer));
- }
-
-ExitSetupPower:
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-
-}
-/*****************************************************************************
- Function : SetStreamingControl
- Description : This Function Enables / Disables the Streaming
- IN PARAM : Pointer to the KSDevice Object
- Streaming Control 1 for ON and 0 for OFF
- OUT PARAM : STATUS_SUCCESS in case of successful Set
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Controls Streaming in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS SetStreamingControl( IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucOnOff)
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Streaming Control (0 = OFF, 1 = ON) = %02d \n",ucOnOff));
-
- //gp8psk_usb_out_op(adap->dev, ARM_TRANSFER, onoff, 0 , NULL, 0);
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- ARM_TRANSFER,
- ucOnOff,
- 0,
- NULL,
- 0,
- false);
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-}
-
-/*****************************************************************************
- Function : SetTunerTone
- Description : This Function Sets the Tuner Tone
- IN PARAM : Pointer to the KSDevice Object
- Tuner Tone : 0 for TONE ON and 1 for TONE OFF
- OUT PARAM : STATUS_SUCCESS in case of successful Set
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Sets the Tuner Tone in case of successful execution
- Logic : NONE
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS SetTunerTone( IN PKSDEVICE pKSDeviceObject,
- IN UCHAR ucTone)
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Tuner Tone (0 = TONE_ON, 1 = TONE_OFF) = %02d \n",ucTone));
-
- //gp8psk_usb_out_op(state->d,SET_22KHZ_TONE,
- // (tone == SEC_TONE_ON), 0, NULL, 0)
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- SET_22KHZ_TONE,
- (ucTone == 0),
- 0,
- NULL,
- 0,
- false);
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-}
-
-/*****************************************************************************
- Function : ConfigureTuner
- Description : This Function Configures Tuner Frequency, Polarity,
- Symbol Rate, Tone etc.
- IN PARAM : Pointer to the KSDevice Object
- Configuration to tune
- OUT PARAM : STATUS_SUCCESS in case of successful Set
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Configures the Tuner with the COnfiguration provided
- Logic : NONE
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS ConfigureTuner(IN PKSDEVICE pKSDeviceObject,
- IN PBDATUNER_DEVICE_PARAMETER pNewConfiguration)
-{
-
- NTSTATUS ntStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- //Set the LNB Voltage based on the Polarity
- if((pNewConfiguration->Polarity == BDA_POLARISATION_LINEAR_H) ||
- (pNewConfiguration->Polarity == BDA_POLARISATION_CIRCULAR_L))
- {
- //Set the LNB Voltage to 18 Volts
- ntStatus = SetLnbVoltage(pKSDeviceObject,SEC_VOLTAGE_18);
- }
- else
- {
- //Set the LNB Voltage to 13 Volts
- ntStatus = SetLnbVoltage(pKSDeviceObject,SEC_VOLTAGE_13);
- }
- if(NT_SUCCESS(ntStatus))
- {
- ntStatus = SetTunerTone(pKSDeviceObject,SEC_TONE_OFF);
- if(NT_SUCCESS(ntStatus))
- {
- //Configure the updated resource on the hardware here.
- ntStatus = TuneDevice(pKSDeviceObject,pNewConfiguration);
- }
- }
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-}
-
-/*****************************************************************************
- Function : DiseqcCommand
- Description : This Function Sends Diseqc Command to the Tuner
- IN PARAM : Pointer to the KSDevice Object
- Command to be sent to the Device
- OUT PARAM : STATUS_SUCCESS in case of successful Set
- Failure Code in other cases
- PreCondition : None
- PostCondtion : Diseqc Command sent to the Tuner
- Logic : 1) Validate the Diseqc Message
- 2) Check the Diseqc Message Length
- 3) If length == 1
- Treat the Diseqc Command as the Simple Tone Burst
- 4) Else
- Treat it as normal Diseqc Command
- Assumption : NONE
- Note : None
- Revision History:
- *****************************************************************************/
-NTSTATUS DiseqcCommand( IN PKSDEVICE pKSDeviceObject,
- IN PDISEQC_COMMAND pCommand)
-{
- NTSTATUS ntStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- if( !IS_VALID(pCommand) ||
- (pCommand->ucMessageLength == 0) ||
- (pCommand->ucMessageLength == 2) ||
- (pCommand->ucMessageLength > MAX_DISEQC_COMMAND_LENGTH))
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Invalid Diseqc Command Received \n"));
- ntStatus = STATUS_INVALID_PARAMETER;
- goto ExitDiseqcCommand;
- }
-
- if(pCommand->ucMessageLength == 1)
- {
- //Simple Tone Burst
- UCHAR ucBurst = (pCommand->ucMessage[0] == SEC_MINI_A) ? 0x00 : 0x01;
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Sending Simple Tone Burst Command = 0x%02X \n",ucBurst));
- //gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, cmd, 0,&cmd, 0)
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- SEND_DISEQC_COMMAND,
- ucBurst,
- 0,
- &ucBurst,
- 0,
- false);
-
- }
- else
- {
- //Normal Diseqc Command
- SkyWalkerDebugPrint(EXTREME_LEVEL,("Sending Normal Diseqc Command\n"));
- PrintDiseqcCommand(pCommand);
- //gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0,m->msg, m->msg_len)
- ntStatus = ControlUsbDevice( pKSDeviceObject,
- SEND_DISEQC_COMMAND,
- pCommand->ucMessage[0],
- 0,
- pCommand->ucMessage,
- pCommand->ucMessageLength,
- false);
-
- }
-
-ExitDiseqcCommand:
-
- PrintFunctionExit(__FUNCTION__,ntStatus);
- return ntStatus;
-}
-
-VOID PrintDiseqcCommand(PDISEQC_COMMAND pDiseqcCommand)
-{
- if(pDiseqcCommand)
- {
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[0] = 0x%02X\n",pDiseqcCommand->ucMessage[0]));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[1] = 0x%02X\n",pDiseqcCommand->ucMessage[1]));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[2] = 0x%02X\n",pDiseqcCommand->ucMessage[2]));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[3] = 0x%02X\n",pDiseqcCommand->ucMessage[3]));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[4] = 0x%02X\n",pDiseqcCommand->ucMessage[4]));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[5] = 0x%02X\n",pDiseqcCommand->ucMessage[5]));
- SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessageLength = %02u\n",pDiseqcCommand->ucMessageLength));
- }
+/*****************************************************************************
+ Company : Shree Ganesha Inc.
+ File Name : SkyWalker1Control.cpp
+ Author :
+ Date :
+ Purpose : This File Holds the Device Control related declarations
+
+ Revision History:
+===============================================================================
+ DATE VERSION AUTHOR REMARK
+===============================================================================
+
+ XXth April,2009 01 Initial Version
+
+*****************************************************************************/
+/* Include the Library and Other header file */
+
+#include "SkyWalker1Main.h" //Common For all the Definitions,
+ //Declarations and Library Routines
+
+/* End of Inclusion the Library and Other header file */
+
+/* Macro Definitions */
+/* End of Macro Definitions */
+
+/* Global & Static variables Declaration */
+/* End of Global & Static variables Declaration */
+
+/* External Variable Declaration */
+/* End of External Variable Declaration */
+
+/* Declare Enumerations here */
+/* End of Enumeration declaration */
+
+/* Function Prototypes */
+VOID PrintDiseqcCommand(PDISEQC_COMMAND pDiseqcCommand);
+/* End of Function prototype definitions */
+
+/*****************************************************************************
+ Function : GetSignalStatus
+ Description : This Function Get the Signal Lock Status
+ IN PARAM : Pointer to the KSDevice Object
+ true in case of Signal Locked else False
+ OUT PARAM : STATUS_SUCCESS in case of successful Lock Read
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Gets the Signal Lock Status in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS GetSignalStatus( IN PKSDEVICE pKSDeviceObject,
+ OUT PBOOLEAN pbSignalLockStatus
+ )
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ UCHAR ucSignalStatus = 0;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0, 0, &lock,1)
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ GET_SIGNAL_LOCK,
+ 0,
+ 0,
+ &ucSignalStatus,
+ 1,
+ true);
+ if(NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("ucSignalStatus = 0x%02X\n",ucSignalStatus));
+
+ if(ucSignalStatus)
+ {
+ *pbSignalLockStatus = TRUE;
+ }
+ else
+ {
+ *pbSignalLockStatus = FALSE;
+ }
+ }
+
+ //if (lock)
+ // *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER;
+ //else
+ // *status = 0;
+
+ if(ucSignalStatus)
+ {
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Signal Lock = 0x%02X\n",*pbSignalLockStatus));
+ }
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+
+}
+
+/*****************************************************************************
+ Function : ReadTunerSignalStrength
+ Description : This Function reads the Tuner Signal Strength
+ IN PARAM : Pointer to the KSDevice Object
+ Pointer to hold the Signal Strength
+ OUT PARAM : STATUS_SUCCESS in case of successful read
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Reads the Signal Strength
+ Logic : NONE
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS ReadTunerSignalStrength( IN PKSDEVICE pKSDeviceObject,
+ OUT PULONG pulSigStrength
+ )
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ UCHAR ucBuffer[6] = {0,0,0,0,0,0};
+ ULONG ulSignalStrength = 0L;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //gp8psk_usb_in_op(st->d, GET_SIGNAL_STRENGTH, 0,0,buf,6);
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ GET_SIGNAL_STRENGTH,
+ 0,
+ 0,
+ ucBuffer,
+ 6,
+ true);
+ if(NT_SUCCESS(ntStatus))
+ {
+ ulSignalStrength = (int)(ucBuffer[1]) << 8 | ucBuffer[0];
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("ulSignalStrength = %lu,ucBuffer[1] = 0x%02X, ucBuffer[2] = 0x%02X\n",
+ ulSignalStrength,ucBuffer[1],ucBuffer[0]));
+ //*pulSigStrength = (int)(ucBuffer[1]) << 8 | ucBuffer[0];
+ /* snr is reported in dBu*256 */
+ /* snr / 38.4 ~= 100% strength */
+ /* snr * 17 returns 100% strength as 65535 */
+ if (ulSignalStrength <= 0x0F00)
+ {
+ *pulSigStrength = (ulSignalStrength <<4) + ulSignalStrength;
+ }
+ else
+ {
+ *pulSigStrength = 0xFFFF;
+ }
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Signal Strength = %lu\n",*pulSigStrength));
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+
+}
+
+/*****************************************************************************
+ Function : SetLnbVoltage
+ Description : This Function Sets the LNB Voltage
+ IN PARAM : Pointer to the KSDevice Object
+ Voltage to set 1 for 18V and 0 for 13V
+ OUT PARAM : STATUS_SUCCESS in case of successful Set
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Sets the LNB Voltage in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS SetLnbVoltage(IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucVoltage)
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ PrintFunctionEntry(__FUNCTION__);
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("New Lnb Voltage (0 = 13V, 1 = 18V) = %02d \n",ucVoltage));
+
+ //gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE,
+ // voltage == SEC_VOLTAGE_18, 0, NULL, 0)
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ SET_LNB_VOLTAGE,
+ (ucVoltage == SEC_VOLTAGE_18),
+ 0,
+ NULL,
+ 0,
+ false);
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+
+
+}
+
+
+/*****************************************************************************
+ Function : TuneDevice
+ Description : This Function Tunes the Tuner
+ IN PARAM : Pointer to the KSDevice Object
+ Tuner parameters to set
+ OUT PARAM : STATUS_SUCCESS in case of successful Set
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Tuners the Tuner in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : To tune the Tuner following command needs to be sent
+ 9 8 7 6 5 4 3 2 1 0
+=================================================================================
+| FECR | MOD | TFQ0 | TFQ0 | TFQ0 | TFQ0 | SBR3 | SBR2 | SBR1 | SBR0 |
+=================================================================================
+Where FECR -> Inner FEC Rate (1 Byte)
+MOD = Modulation = QPSK (1 Byte)
+TF = Tuner Frequency (4 Bytes)
+SBR = Symbol Rate (4 Bytes)
+
+ Revision History:
+ *****************************************************************************/
+NTSTATUS TuneDevice(IN PKSDEVICE pKSDeviceObject,
+ IN PBDATUNER_DEVICE_PARAMETER pDeviceParameter)
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ UCHAR ucCommand[10];
+ ULONG ulTempFrequency = 0L;
+ ULONG ulTunerFrequency = 0L;
+ ULONG ulLOFrequency = 0L;
+ ULONG ulTempSymbolRate = 0L;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Setting the Local Oscillator Frequency
+ if(pDeviceParameter->ulLnbSwitchFrequency >= pDeviceParameter->ulCarrierFrequency)
+ {
+ ulLOFrequency = pDeviceParameter->ulLnbLowLOFrequency;
+ }
+ else
+ {
+ ulLOFrequency = pDeviceParameter->ulLnbHighLOFrequency;
+ }
+
+ //Getting the Frequency to be tuned based on the Carrier frequency and
+ //Local Oscillator frequency (LOF)
+ if(pDeviceParameter->ulCarrierFrequency > ulLOFrequency)
+ {
+ ulTempFrequency = pDeviceParameter->ulCarrierFrequency - ulLOFrequency;
+ }
+ else
+ {
+ ulTempFrequency = ulLOFrequency - pDeviceParameter->ulCarrierFrequency;
+ }
+
+ if( (ulTempFrequency < TUNER_FREQ_MIN) ||
+ (ulTempFrequency > TUNER_FREQ_MAX))
+ {
+ SkyWalkerDebugPrint(EXTREME_LEVEL,
+ ("Frequency Out of Bound %lu, Resetting to %lu\n",
+ ulTempFrequency,TUNER_FREQ_MIN));
+ ulTempFrequency = TUNER_FREQ_MIN;
+ }
+ ulTunerFrequency= ulTempFrequency * pDeviceParameter->ulFrequencyMultiplier;
+
+ //Symbol Rate should be in Sample Per Second thus converting the
+ //Kilo Samples per Second (ksps) to Samples Per Second (sps)
+ ulTempSymbolRate = pDeviceParameter->ulSymbolRate * 1000;
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("New Symbol Rate = %lu sps (%lu ksps)\n"
+ "Carrier Frequency = %lu\n"
+ "Local Oscillator Freq = %lu\n"
+ "Frequency Multiplier = %lu\n"
+ "Tuner Frequency = %lu\n"
+ "New Modulation Type (QPSK = 0)= %lu\n"
+ "New FEC Rate (VITERBI = 1)= %lu \n",
+ ulTempSymbolRate,
+ pDeviceParameter->ulSymbolRate,
+ pDeviceParameter->ulCarrierFrequency,
+ ulLOFrequency,
+ pDeviceParameter->ulFrequencyMultiplier,
+ ulTunerFrequency,
+ ADV_MOD_DVB_QPSK,
+ pDeviceParameter->InnerFecRate));
+
+ ucCommand[0] = (UCHAR)(ulTempSymbolRate & 0xFF);
+ ucCommand[1] = (UCHAR)((ulTempSymbolRate >> 8) & 0xFF);
+ ucCommand[2] = (UCHAR)((ulTempSymbolRate >> 16) & 0xFF);
+ ucCommand[3] = (UCHAR)((ulTempSymbolRate >> 24) & 0xFF);
+
+ ucCommand[4] = (UCHAR)(ulTunerFrequency & 0xFF);
+ ucCommand[5] = (UCHAR)((ulTunerFrequency >> 8) & 0xFF);
+ ucCommand[6] = (UCHAR)((ulTunerFrequency >> 16) & 0xFF);
+ ucCommand[7] = (UCHAR)((ulTunerFrequency >> 24) & 0xFF);
+
+ ucCommand[8] = ADV_MOD_DVB_QPSK;
+ ucCommand[9] = 0x05;
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Tune Command : Symbol Rate = 0x%02X%02X%02X%02X,"
+ "Frequency = 0x%02X%02X%02X%02X",
+ ucCommand[3],ucCommand[2],ucCommand[1],ucCommand[0],
+ ucCommand[7],ucCommand[6],ucCommand[5],ucCommand[4]));
+
+ //gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10);
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ TUNE_8PSK,
+ 0,
+ 0,
+ ucCommand,
+ 10,
+ false);
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+}
+
+/*****************************************************************************
+ Function : SetupTunerPower
+ Description : Function to used to Setup the SkyWalker1 Device Power
+ IN PARAM : Pointer to Device Object which needs Power setup
+ Switch on / Switch Off
+ OUT PARAM : ntStatus of the SkyWalker1 Power Setup
+ STATUS_SUCCESS on Successful execution
+ else Error from the Bus Driver
+ PreCondition : NONE
+ PostCondtion : On Success Device ready for the Operation
+ Logic : Linux Method to Setup the Device
+ 1) Download Firmware (Not done here)
+ 2) Set Power State to ON
+ 3) Read 8PSK Config ntStatus
+ 4) if(Device not Started) then Start it
+ 5) if(BCM4500 Firmware not loaded) then load it
+ 6) if (LNB Power not set) then Set it
+ 7) Set DVB_MODE to 1
+ 8) Read Again the 8PSK Config ntStatus
+ Assumption : NONE
+ Revision History:
+ *****************************************************************************/
+NTSTATUS SetupTunerPower( IN PKSDEVICE pKSDeviceObject,
+ IN BOOLEAN bOnOff)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ UCHAR ucDeviceConfig = 0;
+ UCHAR ucBuffer = 0;
+
+ PrintFunctionEntry(__FUNCTION__);
+
+ if (bOnOff)
+ {
+ //If Tuner Power On
+
+ //Read the Tuner Configuration First
+ //gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1);
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ GET_8PSK_CONFIG,
+ 0,
+ 0,
+ &ucDeviceConfig,
+ 1,
+ true);
+
+ if(!NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Read the Device Configuration\n"));
+ goto ExitSetupPower;
+
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,
+ ("Device Status Bit0:Device Start,Bit1:Firmware Loaded," \
+ "Bit2:LNB Powerup = 0x%02X\n",
+ ucDeviceConfig));
+
+ if (!(ucDeviceConfig & bm8pskStarted)) /* Device Start ntStatus BIT-0 */
+ {
+ //Device Not Started
+ //Send the Boot Command to the Device
+ //gp8psk_usb_in_op(d, BOOT_8PSK, 1, 0, &buf, 1))
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ BOOT_8PSK,
+ 1,
+ 0,
+ &ucBuffer,
+ 1,
+ true);
+ if(!NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Boot the Device\n"));
+ goto ExitSetupPower;
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Boot Response 0x%02X\n",ucBuffer));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Device Bootedup\n"));
+
+ }
+
+ if (!(ucDeviceConfig & bm8pskFW_Loaded)) /* Firmware ntStatus BIT-1 */
+ {
+ //Firmware Not Loaded
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Firmware not Loaded\n"));
+ }
+
+ if (!(ucDeviceConfig & bmIntersilOn)) /* LNB Power Status BIT-2 */
+ {
+ //LNB Not powered On
+ //Sent the Power On Command to the LNB
+ ucBuffer = 0;
+ //gp8psk_usb_in_op(d, START_INTERSIL, 1, 0,&buf, 1))
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ START_INTERSIL,
+ 1,
+ 0,
+ &ucBuffer,
+ 1,
+ true);
+ if(!NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Powerup the Device\n"));
+ goto ExitSetupPower;
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("LNB Powerup Response 0x%02X\n",ucBuffer));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Device Poweredup\n"));
+
+ }
+
+ /* Abort possible TS (if previous tune crashed) */
+ //gp8psk_usb_out_op(d, ARM_TRANSFER, 0, 0, NULL, 0)
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ ARM_TRANSFER,
+ 0,
+ 0,
+ NULL,
+ 0,
+ false);
+
+ //Reread the Device Configuration
+ //gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1);
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ GET_8PSK_CONFIG,
+ 0,
+ 0,
+ &ucDeviceConfig,
+ 1,
+ true);
+
+ if(!NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Read the Device Configuration\n"));
+ goto ExitSetupPower;
+
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,
+ ("Device ntStatus Bit0:Device Start,Bit1:Firmware Loaded," \
+ "Bit2:LNB Powerup = 0x%02X\n",
+ ucDeviceConfig));
+
+
+ }
+ else
+ {
+ //Turn Off LNB Power
+ //gp8psk_usb_in_op(d, START_INTERSIL, 0, 0, &buf, 1)
+ ucBuffer = 0;
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ START_INTERSIL,
+ 0,
+ 0,
+ &ucBuffer,
+ 1,
+ true);
+ if(!NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Powerdown the LNB\n"));
+ goto ExitSetupPower;
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("LNB Powerdown Response 0x%02X\n",ucBuffer));
+
+ //Turn Off 8PSK Power
+ //gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1)
+ ucBuffer = 0;
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ BOOT_8PSK,
+ 0,
+ 0,
+ &ucBuffer,
+ 1,
+ true);
+ if(!NT_SUCCESS(ntStatus))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Unable to Powerdown the SkyWalker1\n"));
+ goto ExitSetupPower;
+ }
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Tuner Powerdown Response 0x%02X\n",ucBuffer));
+ }
+
+ExitSetupPower:
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+
+}
+/*****************************************************************************
+ Function : SetStreamingControl
+ Description : This Function Enables / Disables the Streaming
+ IN PARAM : Pointer to the KSDevice Object
+ Streaming Control 1 for ON and 0 for OFF
+ OUT PARAM : STATUS_SUCCESS in case of successful Set
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Controls Streaming in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS SetStreamingControl( IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucOnOff)
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ PrintFunctionEntry(__FUNCTION__);
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Streaming Control (0 = OFF, 1 = ON) = %02d \n",ucOnOff));
+
+ //gp8psk_usb_out_op(adap->dev, ARM_TRANSFER, onoff, 0 , NULL, 0);
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ ARM_TRANSFER,
+ ucOnOff,
+ 0,
+ NULL,
+ 0,
+ false);
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+}
+
+/*****************************************************************************
+ Function : SetTunerTone
+ Description : This Function Sets the Tuner Tone
+ IN PARAM : Pointer to the KSDevice Object
+ Tuner Tone : 0 for TONE ON and 1 for TONE OFF
+ OUT PARAM : STATUS_SUCCESS in case of successful Set
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Sets the Tuner Tone in case of successful execution
+ Logic : NONE
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS SetTunerTone( IN PKSDEVICE pKSDeviceObject,
+ IN UCHAR ucTone)
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ PrintFunctionEntry(__FUNCTION__);
+
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Tuner Tone (0 = TONE_ON, 1 = TONE_OFF) = %02d \n",ucTone));
+
+ //gp8psk_usb_out_op(state->d,SET_22KHZ_TONE,
+ // (tone == SEC_TONE_ON), 0, NULL, 0)
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ SET_22KHZ_TONE,
+ (ucTone == 0),
+ 0,
+ NULL,
+ 0,
+ false);
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+}
+
+/*****************************************************************************
+ Function : ConfigureTuner
+ Description : This Function Configures Tuner Frequency, Polarity,
+ Symbol Rate, Tone etc.
+ IN PARAM : Pointer to the KSDevice Object
+ Configuration to tune
+ OUT PARAM : STATUS_SUCCESS in case of successful Set
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Configures the Tuner with the COnfiguration provided
+ Logic : NONE
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS ConfigureTuner(IN PKSDEVICE pKSDeviceObject,
+ IN PBDATUNER_DEVICE_PARAMETER pNewConfiguration)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ PrintFunctionEntry(__FUNCTION__);
+
+ //Set the LNB Voltage based on the Polarity
+ if((pNewConfiguration->Polarity == BDA_POLARISATION_LINEAR_H) ||
+ (pNewConfiguration->Polarity == BDA_POLARISATION_CIRCULAR_L))
+ {
+ //Set the LNB Voltage to 18 Volts
+ ntStatus = SetLnbVoltage(pKSDeviceObject,SEC_VOLTAGE_18);
+ }
+ else
+ {
+ //Set the LNB Voltage to 13 Volts
+ ntStatus = SetLnbVoltage(pKSDeviceObject,SEC_VOLTAGE_13);
+ }
+ if(NT_SUCCESS(ntStatus))
+ {
+ ntStatus = SetTunerTone(pKSDeviceObject,SEC_TONE_OFF);
+ if(NT_SUCCESS(ntStatus))
+ {
+ //Configure the updated resource on the hardware here.
+ ntStatus = TuneDevice(pKSDeviceObject,pNewConfiguration);
+ }
+ }
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+}
+
+/*****************************************************************************
+ Function : DiseqcCommand
+ Description : This Function Sends Diseqc Command to the Tuner
+ IN PARAM : Pointer to the KSDevice Object
+ Command to be sent to the Device
+ OUT PARAM : STATUS_SUCCESS in case of successful Set
+ Failure Code in other cases
+ PreCondition : None
+ PostCondtion : Diseqc Command sent to the Tuner
+ Logic : 1) Validate the Diseqc Message
+ 2) Check the Diseqc Message Length
+ 3) If length == 1
+ Treat the Diseqc Command as the Simple Tone Burst
+ 4) Else
+ Treat it as normal Diseqc Command
+ Assumption : NONE
+ Note : None
+ Revision History:
+ *****************************************************************************/
+NTSTATUS DiseqcCommand( IN PKSDEVICE pKSDeviceObject,
+ IN PDISEQC_COMMAND pCommand)
+{
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ PrintFunctionEntry(__FUNCTION__);
+
+ if( !IS_VALID(pCommand) ||
+ (pCommand->ucMessageLength == 0) ||
+ (pCommand->ucMessageLength == 2) ||
+ (pCommand->ucMessageLength > MAX_DISEQC_COMMAND_LENGTH))
+ {
+ SkyWalkerDebugPrint(ENTRY_LEVEL,("Invalid Diseqc Command Received \n"));
+ ntStatus = STATUS_INVALID_PARAMETER;
+ goto ExitDiseqcCommand;
+ }
+
+ if(pCommand->ucMessageLength == 1)
+ {
+ //Simple Tone Burst
+ UCHAR ucBurst = (pCommand->ucMessage[0] == SEC_MINI_A) ? 0x00 : 0x01;
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Sending Simple Tone Burst Command = 0x%02X \n",ucBurst));
+ //gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, cmd, 0,&cmd, 0)
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ SEND_DISEQC_COMMAND,
+ ucBurst,
+ 0,
+ &ucBurst,
+ 0,
+ false);
+
+ }
+ else
+ {
+ //Normal Diseqc Command
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("Sending Normal Diseqc Command\n"));
+ PrintDiseqcCommand(pCommand);
+ //gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0,m->msg, m->msg_len)
+ ntStatus = ControlUsbDevice( pKSDeviceObject,
+ SEND_DISEQC_COMMAND,
+ pCommand->ucMessage[0],
+ 0,
+ pCommand->ucMessage,
+ pCommand->ucMessageLength,
+ false);
+
+ }
+
+ExitDiseqcCommand:
+
+ PrintFunctionExit(__FUNCTION__,ntStatus);
+ return ntStatus;
+}
+
+VOID PrintDiseqcCommand(PDISEQC_COMMAND pDiseqcCommand)
+{
+ if(pDiseqcCommand)
+ {
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[0] = 0x%02X\n",pDiseqcCommand->ucMessage[0]));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[1] = 0x%02X\n",pDiseqcCommand->ucMessage[1]));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[2] = 0x%02X\n",pDiseqcCommand->ucMessage[2]));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[3] = 0x%02X\n",pDiseqcCommand->ucMessage[3]));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[4] = 0x%02X\n",pDiseqcCommand->ucMessage[4]));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessage[5] = 0x%02X\n",pDiseqcCommand->ucMessage[5]));
+ SkyWalkerDebugPrint(EXTREME_LEVEL,("pDiseqcCommand->ucMessageLength = %02u\n",pDiseqcCommand->ucMessageLength));
+ }
}
\ No newline at end of file
diff --git a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Device.cpp b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Device.cpp
index 9464d05..d5fef8c 100644
--- a/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Device.cpp
+++ b/firmware-driver/SkyWalker1_Final_Release/Source/SkyWalker1Device.cpp
@@ -1,1142 +1,1142 @@
-/*****************************************************************************
- Company : Shree Ganesha Inc.
- File Name : SkyWalker1Device.cpp
- Author :
- Date :
- Purpose : Main Skywalker Device level Implementation
-
- Revision History:
-===============================================================================
- DATE VERSION AUTHOR REMARK
-===============================================================================
-
- 01 Initial Version
-
-*****************************************************************************/
-/* Include the Library and Other header file */
-
-#include "SkyWalker1Main.h" //Header for the Tuner related definitions
-
-/* End of Inclusion the Library and Other header file */
-
-/* Macro Definitions */
-/* End of Macro Definitions */
-
-/* Global & Static variables Declaration */
-static ULONG ulDeviceInstance = 0;
-/* End of Global & Static variables Declaration */
-
-/* External Variable Declaration */
-/* End of External Variable Declaration */
-
-/* Declare Enumerations here */
-/* End of Enumeration declaration */
-
-/* Function Prototypes */
-void PrintDMAAdapter(PDMA_ADAPTER pDMAAdapter);
-void PrintMappingInfo(IN PKSMAPPING pMapping);
-
-/* End of Function prototype definitions */
-
-/*****************************************************************************
- Function : CSkyWalker1Device::Create
- Description : This Function is called during the Add Device IRP Processing
- IN PARAM : Pointer to the Enumerated Physical Device
- KSDEVICE is a WDM Functional Device which is managed by the AVStream
- OUT PARAM : ntStatus of the Device Addition
- STATUS_SUCCESS when the Device added to the System
- Reason for Failure incase of Error
- PreCondition : Driver is Loaded without Functional/ Filter Device Objects
- PostCondtion : Functional Device Object [FDO] or Filter Device Object [FiDO] are created
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CSkyWalker1Device::Create(IN PKSDEVICE pKSDeviceObject)
-{
- NTSTATUS ntCreateStatus = STATUS_SUCCESS;
-
- PrintFunctionEntry(__FUNCTION__);
-
- if (pKSDeviceObject)
- {
-
- //Point the KSDEVICE at our device class.
- pKSDeviceObject->Context = this;
-
- m_pKSDevice = pKSDeviceObject;
-
- //Make the resource available for a filter to use.
- m_ulcResourceUsers = 0;
- m_ulCurResourceID = 0;
-
- //Get the instance number of this device.
- m_ulDeviceInstance = ulDeviceInstance++;
-
- //Hold requests until the device is started
- QueueState = HoldRequests;
-
- //Initialize the stop event to signaled.
- KeInitializeEvent(&EvDeviceStopOk, //PKEVENT
- NotificationEvent, //Type
- TRUE); //State
-
- //Initialize the remove event to not-signaled.
- KeInitializeEvent(&EvDeviceRemoveOk, //PKEVENT
- NotificationEvent, //Type
- FALSE); //State
-
- //The KeInitializeSpinLock routine initializes a variable of
- //type KSPIN_LOCK.
- KeInitializeSpinLock(&DeviceStateLock);
- INITIALIZE_PNP_STATE(this);
-
- //OutstandingIo count biased to 1.
- //Transition to 0 during remove device means IO is finished.
- //Transition to 1 means the device can be stopped
-
- ulOutStandingIoCount = 1;
- KeInitializeSpinLock(&kIoCountLock);
-
- }
- else
- {
- SkyWalkerDebugPrint(ENTRY_LEVEL,("Invalid KS Device Object Received\n"));
- ntCreateStatus = STATUS_INVALID_PARAMETER;
- }
-
- PrintFunctionExit(__FUNCTION__,ntCreateStatus);
- return ntCreateStatus;
-}
-
-/*****************************************************************************
- Function : CSkyWalker1Device::Start
- Description : This function Initializes the Tuner Hardware
- IN PARAM : Reference to Device to be Started
- IoRequest Packet
- Resource List
- Translated Resource List
- OUT PARAM : ntStatus of the Tuner Start
- STATUS_SUCCESS in case of successful execution
- Failure Code in other cases
- PreCondition : Stopped Device or Device Enumerated for the First Time
- PostCondtion : Device Initialized with the Newly allocated Resources,
- Logic : NONE
- Assumption : NONE
- Note : NONE
- Revision History:
- *****************************************************************************/
-
-NTSTATUS CSkyWalker1Device::Start(
- IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket,
- IN PCM_RESOURCE_LIST pResourceList OPTIONAL,
- IN PCM_RESOURCE_LIST pTranslatedResourceList OPTIONAL
- )
-{
- NTSTATUS ntStartStatus = STATUS_SUCCESS;
- CSkyWalker1Device * pDevice = NULL;
- PKSFILTERFACTORY pKSFilterFactory = NULL;
-
- PrintFunctionEntry(__FUNCTION__);
-
- pDevice = reinterpret_cast(pKSDeviceObject->Context);
-
- //Initialize the Tuner Hardware.
- ntStartStatus = pDevice->InitializeTuner(pKSDeviceObject,pIoRequestPacket);
- SkyWalkerDebugPrint(EXTREME_LEVEL,("USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE = %d",USBD_DEFAULT_MAXIMUM_TRANSFER_SIZE));
-
- if (ntStartStatus == STATUS_SUCCESS)
- {
- //Create the the Filter Factory. This factory is used to
- //create instances of the filter.
- ntStartStatus = BdaCreateFilterFactoryEx(
- pKSDeviceObject,
- &SkyWalker1TunerFilterDescriptor,
- &TunerFilterTemplate,
- &pKSFilterFactory
- );
- }
-
- if ((ntStartStatus == STATUS_SUCCESS) && pKSFilterFactory)
- {
- BdaFilterFactoryUpdateCacheData(
- pKSFilterFactory,
- TunerFilterTemplate.pFilterDescriptor
- );
- }
-
-
- PrintFunctionExit(__FUNCTION__,ntStartStatus);
- return ntStartStatus;
-}
-
-/*****************************************************************************
- Function : CSkyWalker1Device::Stop
- Description : This routine is invoked when the device is stopped.
- This routine services Irp of minor type IRP_MN_STOP_DEVICE
- IN PARAM : Pointer to KS Device Object
- STOP DEVICE Irp
- OUT PARAM : ntStatus of the Device Stop
- STATUS_SUCCESS on Successful execution
- else Error
- PreCondition : NONE
- PostCondtion : USB Device Stopped
- Logic : NONE
- Assumption : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CSkyWalker1Device::Stop( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket)
-{
- NTSTATUS ntDeviceStopStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- if(m_pDMAAdapter)
- {
- m_pDMAAdapter->DmaOperations->PutDmaAdapter(m_pDMAAdapter);
- m_pDMAAdapter = NULL;
- }
-
- //Maintain the USB ntStatus i.e Remove the Selected Configuration by sending Null descriptor
- ntDeviceStopStatus = StopUsbDevice(pKSDeviceObject,pIoRequestPacket);
-
- PrintFunctionExit(__FUNCTION__,ntDeviceStopStatus);
-
- return ntDeviceStopStatus;
-}
-
-
-/*****************************************************************************
- Function : CSkyWalker1Device::Close
- Description : This routine is invoked when the device is Removed.
- This routine services Irp of minor type IRP_MN_REMOVE_DEVICE
- IN PARAM : Pointer to KS Device Object
- STOP DEVICE Irp
- OUT PARAM : ntStatus of the Device Remove
- STATUS_SUCCESS on Successful execution
- else Error
- PreCondition : NONE
- PostCondtion : USB Device Removed
- Logic : NONE
- Assumption : NONE
- Revision History:
- *****************************************************************************/
-NTSTATUS CSkyWalker1Device::Close( IN PKSDEVICE pKSDeviceObject,
- IN PIRP pIoRequestPacket)
-{
- NTSTATUS ntDeviceCloseStatus = STATUS_SUCCESS;
- PrintFunctionEntry(__FUNCTION__);
-
- ntDeviceCloseStatus = RemoveUsbDevice(pKSDeviceObject,pIoRequestPacket);
-
- PrintFunctionExit(__FUNCTION__,ntDeviceCloseStatus);
-
- return ntDeviceCloseStatus;
-}
-
-/*****************************************************************************
- Function : CSkyWalker1Device::SetPower
- Description : This routine is invoked when the Power Irp is received
- This routine services Irp of minor type IRP_MJ_POWER
- IN PARAM : Pointer to KS Device Object
-