cores/video: Change depth parameter to format (more explicit and we'll maybe want to support other video formats).

This commit is contained in:
Florent Kermarrec 2021-10-08 14:28:04 +02:00
parent 6d317d0882
commit f508b131ea
2 changed files with 11 additions and 8 deletions

View File

@ -606,12 +606,15 @@ class VideoTerminal(Module):
class VideoFrameBuffer(Module, AutoCSR): class VideoFrameBuffer(Module, AutoCSR):
"""Video FrameBuffer""" """Video FrameBuffer"""
def __init__(self, dram_port, hres=800, vres=600, base=0x00000000, fifo_depth=65536, clock_domain="sys", clock_faster_than_sys=False, depth=32): def __init__(self, dram_port, hres=800, vres=600, base=0x00000000, fifo_depth=65536, clock_domain="sys", clock_faster_than_sys=False, format="rgb888"):
self.vtg_sink = vtg_sink = stream.Endpoint(video_timing_layout) self.vtg_sink = vtg_sink = stream.Endpoint(video_timing_layout)
self.source = source = stream.Endpoint(video_data_layout) self.source = source = stream.Endpoint(video_data_layout)
self.underflow = Signal() self.underflow = Signal()
assert((depth == 32) or (depth == 16)) self.depth = depth = {
"rgb888" : 32,
"rgb565" : 16
}[format]
# # # # # #

View File

@ -1784,7 +1784,7 @@ class LiteXSoC(SoC):
self.comb += vt.source.connect(phy if isinstance(phy, stream.Endpoint) else phy.sink) self.comb += vt.source.connect(phy if isinstance(phy, stream.Endpoint) else phy.sink)
# Add Video Framebuffer ------------------------------------------------------------------------ # Add Video Framebuffer ------------------------------------------------------------------------
def add_video_framebuffer(self, name="video_framebuffer", phy=None, timings="800x600@60Hz", clock_domain="sys", depth=32): def add_video_framebuffer(self, name="video_framebuffer", phy=None, timings="800x600@60Hz", clock_domain="sys", format="rgb888"):
# Imports. # Imports.
from litex.soc.cores.video import VideoTimingGenerator, VideoFrameBuffer from litex.soc.cores.video import VideoTimingGenerator, VideoFrameBuffer
@ -1802,9 +1802,9 @@ class LiteXSoC(SoC):
hres = hres, hres = hres,
vres = vres, vres = vres,
base = base, base = base,
format = format,
clock_domain = clock_domain, clock_domain = clock_domain,
clock_faster_than_sys = vtg.video_timings["pix_clk"] > self.sys_clk_freq, clock_faster_than_sys = vtg.video_timings["pix_clk"] > self.sys_clk_freq,
depth = depth
) )
setattr(self.submodules, name, vfb) setattr(self.submodules, name, vfb)
@ -1818,5 +1818,5 @@ class LiteXSoC(SoC):
self.add_constant("VIDEO_FRAMEBUFFER_BASE", base) self.add_constant("VIDEO_FRAMEBUFFER_BASE", base)
self.add_constant("VIDEO_FRAMEBUFFER_HRES", hres) self.add_constant("VIDEO_FRAMEBUFFER_HRES", hres)
self.add_constant("VIDEO_FRAMEBUFFER_VRES", vres) self.add_constant("VIDEO_FRAMEBUFFER_VRES", vres)
self.add_constant("VIDEO_FRAMEBUFFER_DEPTH", depth) self.add_constant("VIDEO_FRAMEBUFFER_DEPTH", vfb.depth)