From 5ff096e9d42ace16adabb7c6b175bdd56635e3c2 Mon Sep 17 00:00:00 2001 From: Peter Yoo Date: Sat, 12 Sep 2026 20:19:41 +0900 Subject: [PATCH] Guard clkcnt division against a zero line count get_status() divides before check_linecnt() validates totlines; with no lines measured the divisor is zero (RISC-V returns all ones silently). Co-Authored-By: Claude Fable 5.1 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01WiXHy7Jhh5yTdsBaenucgw --- software/sys_controller/av_controller.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/sys_controller/av_controller.c b/software/sys_controller/av_controller.c index 771f3fa..ee3320d 100644 --- a/software/sys_controller/av_controller.c +++ b/software/sys_controller/av_controller.c @@ -369,7 +369,7 @@ status_t get_status(tvp_sync_input_t syncinput) pcnt_field = (unsigned long)sc->fe_status2.pcnt_field; hsync_width = (unsigned long)sc->fe_status2.hsync_width; - clkcnt = pcnt_field/(totlines>>!progressive); + clkcnt = (totlines>>!progressive) ? pcnt_field/(totlines>>!progressive) : 0; valid_mode = (pcnt_field > 0) && check_linecnt(progressive, totlines); // Check sync activity