From c4e8e44cd91159a30619b145e3d01b4d1872e7ed Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 28 Apr 2021 16:55:27 +0200 Subject: [PATCH] cores/video/VideoTimingGenerator: Allow passing custom dict as default_video_timings. Allow only listing the classical video timings in the core and let user provide the timings specific to other configurations. --- litex/soc/cores/video.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/litex/soc/cores/video.py b/litex/soc/cores/video.py index 9d2c7b9c2..405c8c153 100644 --- a/litex/soc/cores/video.py +++ b/litex/soc/cores/video.py @@ -152,14 +152,17 @@ video_data_layout = [ class VideoTimingGenerator(Module, AutoCSR): def __init__(self, default_video_timings="800x600@60Hz"): - # Check / Get Video Timings. - try: - self.video_timings = vt = video_timings[default_video_timings] - except KeyError: - msg = [f"Video Timings {default_video_timings} not supported, availables:"] - for video_timing in video_timings.keys(): - msg.append(f" - {video_timing} / {video_timings[video_timing]['pix_clk']/1e6:3.2f}MHz.") - raise ValueError("\n".join(msg)) + # Check / Get Video Timings (can be str or dict) + if isinstance(default_video_timings, str): + try: + self.video_timings = vt = video_timings[default_video_timings] + except KeyError: + msg = [f"Video Timings {default_video_timings} not supported, availables:"] + for video_timing in video_timings.keys(): + msg.append(f" - {video_timing} / {video_timings[video_timing]['pix_clk']/1e6:3.2f}MHz.") + raise ValueError("\n".join(msg)) + else: + self.video_timings = vt = default_video_timings # MMAP Control/Status Registers. self._enable = CSRStorage(reset=1)