summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/clkcalc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/clkcalc.c b/tools/clkcalc.c
index 2829ca9..cc5b932 100644
--- a/tools/clkcalc.c
+++ b/tools/clkcalc.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdint.h>
double _fabs(double a)
{
@@ -31,19 +32,19 @@ int main(int argc, char *argv[])
int fs = atoi(argv[1]);
int bw = atoi(argv[2]);
int ch = atoi(argv[3]);
-
+
int target = fs * bw * ch;
int cclk = 100000000;
result_t res;
- res.pclkdiv_idx = 0;
+ res.pclkdiv_idx = 3;
res.bitrate = 0;
res.x = 1;
res.y = 1;
- for(;res.pclkdiv_idx < 4; res.pclkdiv_idx++) {
+ for(;res.pclkdiv_idx >= 0; res.pclkdiv_idx--) {
double clk = (cclk / pclkdiv[res.pclkdiv_idx]);
@@ -51,7 +52,8 @@ int main(int argc, char *argv[])
double clk_y = clk / (double)res.y;
- for(res.x = 1; res.x < 256; res.x++) {
+ // Note y must be greater than or equal to x.
+ for(res.x = 1; res.x <= res.y; res.x++) {
double clk_y_x_2 = (clk_y * (double)res.x) / 2.0;