![]() |
piSmasher Configuration Libraries
piSmasher peripheral device configuration libraries
|
Video Timing Controller Userspace I/O Driver FreeBSD. More...
#include <sys/mman.h>#include <sys/time.h>#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <stdbool.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include "vtc.h"Data Structures | |
| struct | vtc_polarity |
| struct | vtc_hoffset |
| struct | vtc_signal |
| struct | vtc_timing |
Macros | |
| #define | ERR_MODE_INVALID (0x0100U) |
| #define | ERR_NULL_PARAM (0x0101U) |
| #define | VTC_REG_CONTROL (0x00000000U) |
| #define | VTC_REG_STATUS (0x00000004U) |
| #define | VTC_REG_ERROR (0x00000008U) |
| #define | VTC_REG_IRQ_ENABLE (0x0000000CU) |
| #define | VTC_REG_VERSION (0x00000010U) |
| #define | VTC_REG_DET_ASIZE (0x00000020U) |
| #define | VTC_REG_DET_STATUS (0x00000024U) |
| #define | VTC_REG_DET_ENC (0x00000028U) |
| #define | VTC_REG_DET_POL (0x0000002CU) |
| #define | VTC_REG_DET_HSIZE (0x00000030U) |
| #define | VTC_REG_DET_VSIZE (0x00000034U) |
| #define | VTC_REG_DET_HSYNC (0x00000038U) |
| #define | VTC_REG_DET_VBLANK_F0 (0x0000003CU) |
| #define | VTC_REG_DET_VSYNC_V_F0 (0x00000040U) |
| #define | VTC_REG_DET_VSYNC_H_F0 (0x00000044U) |
| #define | VTC_REG_DET_VBLANK_F1 (0x00000048U) |
| #define | VTC_REG_DET_VSYNC_V_F1 (0x0000004CU) |
| #define | VTC_REG_DET_VSYNC_H_F1 (0x00000050U) |
| #define | VTC_REG_GEN_ASIZE (0x00000060U) |
| #define | VTC_REG_GEN_STATUS (0x00000064U) |
| #define | VTC_REG_GEN_ENC (0x00000068U) |
| #define | VTC_REG_GEN_POL (0x0000006CU) |
| #define | VTC_REG_GEN_HSIZE (0x00000070U) |
| #define | VTC_REG_GEN_VSIZE (0x00000074U) |
| #define | VTC_REG_GEN_HSYNC (0x00000078U) |
| #define | VTC_REG_GEN_VBLANK_F0 (0x0000007CU) |
| #define | VTC_REG_GEN_VSYNC_V_F0 (0x00000080U) |
| #define | VTC_REG_GEN_VSYNC_H_F0 (0x00000084U) |
| #define | VTC_REG_GEN_VBLANK_F1 (0x00000088U) |
| #define | VTC_REG_GEN_VSYNC_V_F1 (0x0000008CU) |
| #define | VTC_REG_GEN_VSYNC_H_F1 (0x00000090U) |
| #define | CONTROL_SW_ENABLE (1 << 0) |
| #define | CONTROL_REG_UPDATE (1 << 1) |
| #define | CONTROL_GEN_ENABLE (1 << 2) |
| #define | CONTROL_DET_ENABLE (1 << 3) |
| #define | CONTROL_SYNC_ENABLE (1 << 5) |
| #define | CONTROL_FRAME_HSIZE_SRC (1 << 8) |
| #define | CONTROL_ACTIVE_HSIZE_SRC (1 << 9) |
| #define | CONTROL_HSYNC_START_SRC (1 << 10) |
| #define | CONTROL_HSYNC_END_SRC (1 << 11) |
| #define | CONTROL_FRAME_VSIZE_SRC (1 << 13) |
| #define | CONTROL_ACTIVE_VSIZE_SRC (1 << 14) |
| #define | CONTROL_VSYNC_START_SRC (1 << 15) |
| #define | CONTROL_VSYNC_END_SRC (1 << 16) |
| #define | CONTROL_VBLANK_HOFF_SRC (1 << 17) |
| #define | CONTROL_CHROMA_SRC (1 << 18) |
| #define | CONTROL_VBLANK_POL_SRC (1 << 20) |
| #define | CONTROL_HBLANK_POL_SRC (1 << 21) |
| #define | CONTROL_VSYNC_POL_SRC (1 << 22) |
| #define | CONTROL_HSYNC_POL_SRC (1 << 23) |
| #define | CONTROL_ACTIVE_VIDEO_POL_SRC (1 << 24) |
| #define | CONTROL_ACTIVE_CHROMA_POL_SRC (1 << 25) |
| #define | CONTROL_FIELD_ID_POL_SRC (1 << 26) |
| #define | CONTROL_FSYNC_RESET (1 << 30) |
| #define | CONTROL_SW_RESET (1 << 31) |
| #define | STATUS_LOCK (1 << 8) |
| #define | STATUS_LOCK_LOSS (1 << 9) |
| #define | STATUS_DET_VBLANK (1 << 10) |
| #define | STATUS_DET_ACTIVE_VIDEO (1 << 11) |
| #define | STATUS_GEN_VBLANK (1 << 12) |
| #define | STATUS_GEN_ACTIVE_VIDEO (1 << 13) |
| #define | STATUS_FSYNC_MASK (0xFFFF0000U) |
| #define | ERROR_VBLANK_LOCK (1 << 16) |
| #define | ERROR_HBLANK_LOCK (1 << 17) |
| #define | ERROR_VSYNC_LOCK (1 << 18) |
| #define | ERROR_HSYNC_LOCK (1 << 19) |
| #define | ERROR_ACTIVE_VIDEO_LOCK (1 << 20) |
| #define | ERROR_ACTIVE_CHROMA_LOCK (1 << 21) |
| #define | IRQ_ENABLE_LOCK (1 << 8) |
| #define | IRQ_ENABLE_LOCK_LOSS (1 << 9) |
| #define | IRQ_ENABLE_DET_VBLANK (1 << 10) |
| #define | IRQ_ENABLE_DET_ACTIVE_VIDEO (1 << 11) |
| #define | IRQ_ENABLE_GEN_VBLANK (1 << 12) |
| #define | IRQ_ENABLE_GEN_ACTIVE_VIDEO (1 << 13) |
| #define | IRQ_ENABLE_FSYNC_MASK (0xFFFF0000U) |
| #define | GEN_ASIZE_HSIZE (0x00001FFFU) |
| #define | GEN_ASIZE_VSIZE (0x1FFF0000U) |
| #define | GEN_STATUS_VBLANK (1 << 1) |
| #define | GEN_STATUS_ACTIVE_VIDEO (1 << 2) |
| #define | GEN_ENC_VIDEO_FORMAT_MASK (0x000000FFU) |
| #define | GEN_ENC_INTERLACED (1 << 6) |
| #define | GEN_ENC_FIELD_ID_PARITY (1 << 7) |
| #define | GEN_ENC_CHROMA_PARITY_MASK (0x00000300U) |
| #define | GEN_POL_VBLANK (1 << 0) |
| #define | GEN_POL_HBLANK (1 << 1) |
| #define | GEN_POL_VSYNC (1 << 2) |
| #define | GEN_POL_HSYNC (1 << 3) |
| #define | GEN_POL_ACTIVE_VIDEO (1 << 4) |
| #define | GEN_POL_ACTIVE_CHROMA (1 << 5) |
| #define | GEN_POL_FIELD_ID (1 << 6) |
| #define | GEN_POL_ALL_MASK (0x0000007FU) |
| #define | GEN_HSIZE_MASK (0x00001FFFU) |
| #define | GEN_VSIZE_MASK (0x00001FFFU) |
| #define | GEN_HSYNC_START_MASK (0x00001FFFU) |
| #define | GEN_HSYNC_END_MASK (0x1FFF0000U) |
| #define | GEN_VBLANK_HSTART_MASK (0x00001FFFU) |
| #define | GEN_VBLANK_HEND_MASK (0x1FFF0000U) |
| #define | GEN_VSYNC_VSTART_MASK (0x00001FFFU) |
| #define | GEN_VSYNC_VEND_MASK (0x1FFF0000U) |
| #define | GEN_VSYNC_HSTART_MASK (0x00001FFFU) |
| #define | GEN_VSYNC_HEND_MASK (0x1FFF0000U) |
| #define | REG_READ(__BASE__, __OFFSET__) *((volatile uint32_t *)(((uint8_t *)(__BASE__)) + (__OFFSET__))) |
| #define | REG_WRITE(__BASE__, __OFFSET__, __DATA__) *((volatile uint32_t *)(((uint8_t *)(__BASE__)) + (__OFFSET__))) = (__DATA__) |
| #define | GEN_POL_VBLANK (1 << 0) |
| #define | GEN_POL_HBLANK (1 << 1) |
| #define | GEN_POL_VSYNC (1 << 2) |
| #define | GEN_POL_HSYNC (1 << 3) |
| #define | GEN_POL_ACTIVE_VIDEO (1 << 4) |
| #define | GEN_POL_ACTIVE_CHROMA (1 << 5) |
| #define | GEN_POL_FIELD_ID (1 << 6) |
Functions | |
| struct vtc_timing * | vtc_mode2tim (struct vtc_dev *dev, enum vtc_mode mode) |
| static void | vtc_write_start_end (struct vtc_dev *dev, uint32_t reg, uint32_t start, uint32_t end) |
| void | vtc_tim2sig (struct vtc_dev *dev, struct vtc_timing *timing, struct vtc_signal *signal, struct vtc_hoffset *hoffset, struct vtc_polarity *pol) |
| static int | vtc_reset (struct vtc_dev *dev) |
| int | vtc_enable (struct vtc_dev *dev, bool en) |
| Enable Video Timing Controller. More... | |
| int | vtc_gen_enable (struct vtc_dev *dev, bool en) |
| Enable Video Timing Generator. More... | |
| int | vtc_det_enable (struct vtc_dev *dev, bool en) |
| Enable Video Timing Detector. | |
| int | vtc_det_dump (struct vtc_dev *dev) |
| void | vtc_set_polarity (struct vtc_dev *dev, struct vtc_polarity *pol) |
| Set Polarity. | |
| uint32_t | vtc_get_version (struct vtc_dev *dev) |
| Get Version. | |
| static void | vtc_set_genenerator_hoffset (struct vtc_dev *dev, struct vtc_hoffset *hoffset) |
| static void | vtc_set_generator (struct vtc_dev *dev, struct vtc_signal *signal) |
| int | vtc_set_generator_timing (struct vtc_dev *dev, struct vtc_timing *timing) |
| Set Video Timing Generator Timing. | |
| int | vtc_set_generator_video_mode (struct vtc_dev *dev, enum vtc_mode mode) |
| Set Video Generator Video Mode. | |
| int | vtc_enable_interrupts (struct vtc_dev *dev) |
| int | vtc_init (struct vtc_dev *dev, const char *devname) |
| Video Timing Controller Initialization. | |
Variables | |
| static struct vtc_timing | video_timing [] |
Video Timing Controller Userspace I/O Driver FreeBSD.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project.
| #define CONTROL_ACTIVE_CHROMA_POL_SRC (1 << 25) |
Active chroma polarity source select
| #define CONTROL_ACTIVE_HSIZE_SRC (1 << 9) |
Generator horizontal active size source select
| #define CONTROL_ACTIVE_VIDEO_POL_SRC (1 << 24) |
Active video polarity source select
| #define CONTROL_ACTIVE_VSIZE_SRC (1 << 14) |
Generator vertical active size source select
| #define CONTROL_CHROMA_SRC (1 << 18) |
Generator chroma polarity and encoding source select
| #define CONTROL_DET_ENABLE (1 << 3) |
Detection enable
| #define CONTROL_FIELD_ID_POL_SRC (1 << 26) |
Field ID polarity source select
| #define CONTROL_FRAME_HSIZE_SRC (1 << 8) |
Generator horizontal frame size source select
| #define CONTROL_FRAME_VSIZE_SRC (1 << 13) |
Generator vertical frame size source select
| #define CONTROL_FSYNC_RESET (1 << 30) |
Frame Sync Core reset
| #define CONTROL_GEN_ENABLE (1 << 2) |
Generation enable
| #define CONTROL_HBLANK_POL_SRC (1 << 21) |
Horizontal blank polarity source select
| #define CONTROL_HSYNC_END_SRC (1 << 11) |
Generator horizontal sync end source select
| #define CONTROL_HSYNC_POL_SRC (1 << 23) |
Horizontal sync polarity source select
| #define CONTROL_HSYNC_START_SRC (1 << 10) |
Generator horizontal sync start source select
| #define CONTROL_REG_UPDATE (1 << 1) |
Register update. Generator and Fsync registers are double-buffered.
| #define CONTROL_SW_ENABLE (1 << 0) |
Core enable
| #define CONTROL_SW_RESET (1 << 31) |
Core reset
| #define CONTROL_SYNC_ENABLE (1 << 5) |
Generator synchronization enable
| #define CONTROL_VBLANK_HOFF_SRC (1 << 17) |
Generator vertical blank offset source select
| #define CONTROL_VBLANK_POL_SRC (1 << 20) |
Vertical Blank Polarity Source Select
| #define CONTROL_VSYNC_END_SRC (1 << 16) |
Generator vertical sync end source select
| #define CONTROL_VSYNC_POL_SRC (1 << 22) |
Vertical sync polarity source select
| #define CONTROL_VSYNC_START_SRC (1 << 15) |
Generator vertical sync start source select
| #define ERROR_ACTIVE_CHROMA_LOCK (1 << 21) |
Active chroma lock status
| #define ERROR_ACTIVE_VIDEO_LOCK (1 << 20) |
Active video lock status
| #define ERROR_HBLANK_LOCK (1 << 17) |
Horizontal blank lock status
| #define ERROR_HSYNC_LOCK (1 << 19) |
Horizontal sync lock status
| #define ERROR_VBLANK_LOCK (1 << 16) |
Vertical blank lock status
| #define ERROR_VSYNC_LOCK (1 << 18) |
Vertical sync lock status
| #define GEN_ASIZE_HSIZE (0x00001FFFU) |
Generated horizontal active frame size
| #define GEN_ASIZE_VSIZE (0x1FFF0000U) |
Generated vertical active frame size
| #define GEN_ENC_CHROMA_PARITY_MASK (0x00000300U) |
Generated chroma parity
| #define GEN_ENC_FIELD_ID_PARITY (1 << 7) |
Generated field ID parity
| #define GEN_ENC_INTERLACED (1 << 6) |
Generated video interlaced format
| #define GEN_ENC_VIDEO_FORMAT_MASK (0x000000FFU) |
Generated video format
| #define GEN_HSIZE_MASK (0x00001FFFU) |
Generated horizontal frame size
| #define GEN_HSYNC_END_MASK (0x1FFF0000U) |
Generated horizontal sync end end cycle index
| #define GEN_HSYNC_START_MASK (0x00001FFFU) |
Generated horizontal sync end start cycle index
| #define GEN_POL_ACTIVE_CHROMA (1 << 5) |
Generated active chroma polarity
| #define GEN_POL_ACTIVE_CHROMA (1 << 5) |
Generated active chroma polarity
| #define GEN_POL_ACTIVE_VIDEO (1 << 4) |
Generated active video polarity
| #define GEN_POL_ACTIVE_VIDEO (1 << 4) |
Generated active video polarity
| #define GEN_POL_ALL_MASK (0x0000007FU) |
All polarity bits
| #define GEN_POL_FIELD_ID (1 << 6) |
Generated field ID polarity
| #define GEN_POL_FIELD_ID (1 << 6) |
Generated field ID polarity
| #define GEN_POL_HBLANK (1 << 1) |
Generated horizontal blank polarity
| #define GEN_POL_HBLANK (1 << 1) |
Generated horizontal blank polarity
| #define GEN_POL_HSYNC (1 << 3) |
Generated horizontal sync polarity
| #define GEN_POL_HSYNC (1 << 3) |
Generated horizontal sync polarity
| #define GEN_POL_VBLANK (1 << 0) |
Generated vertical blank polarity
| #define GEN_POL_VBLANK (1 << 0) |
Generated vertical blank polarity
| #define GEN_POL_VSYNC (1 << 2) |
Generated vertical sync polarity
| #define GEN_POL_VSYNC (1 << 2) |
Generated vertical sync polarity
| #define GEN_STATUS_ACTIVE_VIDEO (1 << 2) |
Generated active video interrupt status
| #define GEN_STATUS_VBLANK (1 << 1) |
Generated vertical blank interrupt status
| #define GEN_VBLANK_HEND_MASK (0x1FFF0000U) |
Generated vertical blank horizontal start end cycle index
| #define GEN_VBLANK_HSTART_MASK (0x00001FFFU) |
Generated vertical blank horizontal start start cycle index
| #define GEN_VSIZE_MASK (0x00001FFFU) |
Generated vertical frame size
| #define GEN_VSYNC_HEND_MASK (0x1FFF0000U) |
Generated vertical sync horizontal start end cycle index
| #define GEN_VSYNC_HSTART_MASK (0x00001FFFU) |
Generated vertical sync horizontal start start cycle index
| #define GEN_VSYNC_VEND_MASK (0x1FFF0000U) |
Generated vertical sync vertical start end cycle index
| #define GEN_VSYNC_VSTART_MASK (0x00001FFFU) |
Generated vertical sync vertical start start cycle index
| #define IRQ_ENABLE_DET_ACTIVE_VIDEO (1 << 11) |
Detected active video interrupt enable
| #define IRQ_ENABLE_DET_VBLANK (1 << 10) |
Detected vertical blank interrupt enable
| #define IRQ_ENABLE_FSYNC_MASK (0xFFFF0000U) |
Frame synchronization interrupt enable
| #define IRQ_ENABLE_GEN_ACTIVE_VIDEO (1 << 13) |
Generated active video interrupt enable
| #define IRQ_ENABLE_GEN_VBLANK (1 << 12) |
Generated vertical blank interrupt enable
| #define IRQ_ENABLE_LOCK (1 << 8) |
Lock interrupt enable
| #define IRQ_ENABLE_LOCK_LOSS (1 << 9) |
Loss-of-lock interrupt enable
| #define STATUS_DET_ACTIVE_VIDEO (1 << 11) |
Detected active video interrupt status
| #define STATUS_DET_VBLANK (1 << 10) |
Detected vertival blank interrupt status
| #define STATUS_FSYNC_MASK (0xFFFF0000U) |
Fsync interrupt status
| #define STATUS_GEN_ACTIVE_VIDEO (1 << 13) |
Generated active video interrupt status
| #define STATUS_GEN_VBLANK (1 << 12) |
Generated vertical blank interrupt status
| #define STATUS_LOCK (1 << 8) |
Lock status
| #define STATUS_LOCK_LOSS (1 << 9) |
Loss-of-lock status
| #define VTC_REG_CONTROL (0x00000000U) |
Control
| #define VTC_REG_DET_ASIZE (0x00000020U) |
Frame size (without blanking)
| #define VTC_REG_DET_ENC (0x00000028U) |
Frame encoding
| #define VTC_REG_DET_HSIZE (0x00000030U) |
Horizontal frame size (with blanking)
| #define VTC_REG_DET_HSYNC (0x00000038U) |
Hsync start and end cycle index
| #define VTC_REG_DET_POL (0x0000002CU) |
Blanking/sync polarity
| #define VTC_REG_DET_STATUS (0x00000024U) |
Timing measurement status
| #define VTC_REG_DET_VBLANK_F0 (0x0000003CU) |
Vblank start and end cycle index (field 0)
| #define VTC_REG_DET_VBLANK_F1 (0x00000048U) |
Start and end cycle index of VBlank for field 1
| #define VTC_REG_DET_VSIZE (0x00000034U) |
Vertical frame size (with blanking)
| #define VTC_REG_DET_VSYNC_H_F0 (0x00000044U) |
Start and end cycle index of VSync for field 0
| #define VTC_REG_DET_VSYNC_H_F1 (0x00000050U) |
Start and end cycle index of VSync for field 1
| #define VTC_REG_DET_VSYNC_V_F0 (0x00000040U) |
Start and end line index of VSync for field 0
| #define VTC_REG_DET_VSYNC_V_F1 (0x0000004CU) |
Start and end line index of VSync for field 1
| #define VTC_REG_ERROR (0x00000008U) |
Status/error
| #define VTC_REG_GEN_ASIZE (0x00000060U) |
Generator frame size (without blanking) (R/W)
| #define VTC_REG_GEN_ENC (0x00000068U) |
Generator frame encoding (R/W)
| #define VTC_REG_GEN_HSIZE (0x00000070U) |
Generator horizontal frame size (with blanking) (R/W)
| #define VTC_REG_GEN_HSYNC (0x00000078U) |
Generator hsync start and end cycle index
| #define VTC_REG_GEN_POL (0x0000006CU) |
Generator blank and sync polarities (R/W)
| #define VTC_REG_GEN_STATUS (0x00000064U) |
Generator timing measurement status (RO)
| #define VTC_REG_GEN_VBLANK_F0 (0x0000007CU) |
Generator vblank start and end cycle index of vsync for field 0
| #define VTC_REG_GEN_VBLANK_F1 (0x00000088U) |
Generator vblank start and end line index of vsync for field 1
| #define VTC_REG_GEN_VSIZE (0x00000074U) |
Generator vertical frame size (with blanking) (R/W)
| #define VTC_REG_GEN_VSYNC_H_F0 (0x00000084U) |
Generator vsync start and end line index of vsync for field 0
| #define VTC_REG_GEN_VSYNC_H_F1 (0x00000090U) |
Generator vsync start and end cycle index of vsync for field 1
| #define VTC_REG_GEN_VSYNC_V_F0 (0x00000080U) |
Generator vsync start and end line index of vsync for field 0
| #define VTC_REG_GEN_VSYNC_V_F1 (0x0000008CU) |
Generator vsync start and end line index of vsync for field 1
| #define VTC_REG_IRQ_ENABLE (0x0000000CU) |
Interrupt enable/clear
| #define VTC_REG_STATUS (0x00000004U) |
Core/interrupt status
| #define VTC_REG_VERSION (0x00000010U) |
Core version
| int vtc_enable | ( | struct vtc_dev * | dev, |
| bool | en | ||
| ) |
Enable Video Timing Controller.
| dev | Video timing controller device structure pointer |
| en | Enable timing controller selection |
| int vtc_gen_enable | ( | struct vtc_dev * | dev, |
| bool | en | ||
| ) |
Enable Video Timing Generator.
| dev | Video timing controller device structure pointer |
| en | Enable generator selection |