33#if __has_include("esp32/rom/lldesc.h")
34 #include "esp32/rom/lldesc.h"
36 #include "rom/lldesc.h"
38#include "soc/i2s_struct.h"
39#include "soc/sens_struct.h"
57 double subcarrierFreq_hz;
72 uint8_t frameGroupCount;
73 int8_t preEqualizingPulseCount;
74 int8_t vsyncPulseCount;
75 int8_t postEqualizingPulseCount;
76 int8_t endFieldEqualizingPulseCount;
81 uint16_t defaultVisibleSamples;
82 uint16_t defaultVisibleLines;
83 uint8_t fieldStartingLine[2];
85 uint8_t interlaceFactor;
92 virtual bool lineHasColorBurst(
int frame,
int frameLine)
const = 0;
95 virtual double getComposite(
bool oddLine,
double phase,
double red,
double green,
double blue,
double *
Y)
const = 0;
98 virtual double getColorBurst(
bool oddLine,
double phase)
const = 0;
103#define CVBS_ALLOCATED_LINES 4
107#define CVBS_SUBCARRIERPHASES 100
109#if CVBS_SUBCARRIERPHASES > 128
110 typedef uint16_t scPhases_t;
112 typedef uint8_t scPhases_t;
116#define CVBS_NOBURSTFLAG (CVBS_SUBCARRIERPHASES * 2 - 1)
119#if FABGLIB_CVBSCONTROLLER_PERFORMANCE_CHECK
120 extern volatile uint64_t s_cvbsctrlcycles;
124typedef void (*CVBSDrawScanlineCallback)(
void * arg, uint16_t * dest,
int destSample,
int scanLine);
136 void setVideoGPIO(gpio_num_t gpio);
138 void setDrawScanlineCallback(CVBSDrawScanlineCallback drawScanlineCallback,
void * arg =
nullptr);
140 void setup(
char const * desc);
141 void setup(CVBSParams
const * params);
143 static CVBSParams
const * getParamsFromDesc(
char const * desc);
145 void run(
bool subCarrierOnly =
false);
150 void setConstDAC(uint8_t value) {
152 I2S0.conf_single_data = value << 24;
155 static bool VSync() {
return s_VSync; }
156 static int field() {
return s_field; }
157 static int frame() {
return s_frame; }
158 static int frameLine() {
return s_frameLine; }
159 static int subCarrierPhase() {
return *s_subCarrierPhase; }
160 static int pictureLine() {
return s_scanLine; }
161 static bool lineSwitch() {
return s_lineSwitch; }
162 static scPhases_t * lineSampleToSubCarrierSample() {
return (scPhases_t*) s_lineSampleToSubCarrierSample; }
163 static int firstVisibleSample() {
return s_firstVisibleSample; }
165 int visibleLines() {
return m_visibleLines; }
166 int visibleSamples() {
return s_visibleSamplesCount; }
168 CVBSParams
const * params() {
return m_params; }
173 void runDMA(lldesc_t
volatile * dmaBuffers);
174 volatile lldesc_t * setDMANode(
int index,
volatile uint16_t * buf,
int len);
175 void closeDMAChain(
int index);
176 void buildDMAChain();
177 void buildDMAChain_subCarrierOnly();
178 void addExtraSamples(
double us,
double * aus,
int * node);
179 static void ISRHandler(
void * arg);
183 static volatile int s_scanLine;
184 static volatile bool s_VSync;
185 static volatile int s_field;
186 static volatile int s_frame;
187 static volatile int s_frameLine;
188 static volatile int s_activeLineIndex;
189 static volatile scPhases_t * s_subCarrierPhase;
190 static volatile bool s_lineSwitch;
194 lldesc_t
volatile * m_DMAChain;
197 volatile uint16_t * m_lsyncBuf;
198 volatile uint16_t * m_ssyncBuf;
199 volatile uint16_t * * m_lineBuf;
202 volatile uint16_t * m_blackBuffer;
203 int m_blackBufferLength;
206 intr_handle_t m_isr_handle;
207 static volatile int16_t s_visibleSamplesCount;
208 static volatile int16_t s_firstVisibleSample;
209 CVBSDrawScanlineCallback m_drawScanlineCallback;
210 void * m_drawScanlineArg;
211 volatile int16_t m_visibleLines;
212 int16_t m_firstVisibleFieldLine;
213 int16_t m_lastVisibleFieldLine;
214 volatile int16_t m_firstActiveFrameLine[2];
215 volatile int16_t m_firstVisibleFrameLine[2];
216 volatile int16_t m_lastVisibleFrameLine[2];
217 volatile int16_t m_startingScanLine[2];
218 volatile scPhases_t * m_subCarrierPhases[4];
219 volatile uint16_t m_colorBurstLUT[2][CVBS_SUBCARRIERPHASES * 2];
220 volatile uint16_t m_firstColorBurstSample;
221 volatile uint16_t m_lastColorBurstSample;
222 volatile int m_linesPerFrame;
223 static volatile scPhases_t * s_lineSampleToSubCarrierSample;
224 double m_actualLine_us;
225 double m_actualHLine_us;
227 bool m_firstActiveFieldLineSwitch[4][2];
229 CVBSParams
const * m_params;
This file contains FabGL library configuration settings, like number of supported colors,...