From 384088bd2d8c91129a926bd249af6d9b9c533972 Mon Sep 17 00:00:00 2001 From: David Banks Date: Tue, 12 Mar 2019 18:52:09 +0000 Subject: [PATCH] Pi Firmware: Added half-odd and half-even sampling to cpld_normal Change-Id: I77441db0a8cad66f3bf4d24f50e7b0e16e72a55c --- src/cpld.h | 1 + src/cpld_atom.c | 5 +++++ src/cpld_normal.c | 44 ++++++++++++++++++++++++++++++----------- src/osd.c | 5 +++++ src/scripts/cmdline.txt | 2 +- 5 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/cpld.h b/src/cpld.h index 8d3d8875..0355f637 100644 --- a/src/cpld.h +++ b/src/cpld.h @@ -29,6 +29,7 @@ typedef struct { // Support for the UI param_t *(*get_params)(); int (*get_value)(int num); + const char *(*get_value_string)(int num); void (*set_value)(int num, int value); // Support for info page void (*show_cal_summary)(int line); diff --git a/src/cpld_atom.c b/src/cpld_atom.c index b97d02f6..cac1b9ca 100644 --- a/src/cpld_atom.c +++ b/src/cpld_atom.c @@ -208,6 +208,10 @@ static int cpld_get_value(int num) { return 0; } +static const char *cpld_get_value_string(int num) { + return NULL; +} + static void cpld_set_value(int num, int value) { switch (num) { case OFFSET: @@ -250,6 +254,7 @@ cpld_t cpld_atom = { .update_capture_info = cpld_update_capture_info, .get_params = cpld_get_params, .get_value = cpld_get_value, + .get_value_string = cpld_get_value_string, .set_value = cpld_set_value, .show_cal_summary = cpld_show_cal_summary, .show_cal_details = cpld_show_cal_details diff --git a/src/cpld_normal.c b/src/cpld_normal.c index 1f732068..bc340f0a 100644 --- a/src/cpld_normal.c +++ b/src/cpld_normal.c @@ -19,9 +19,16 @@ typedef struct { int half_px_delay; // 0 = off, 1 = on, all modes int divider; // cpld divider, 6 or 8 int full_px_delay; // 0..15 - int rate; // 0 = normal psync rate (3 bpp), 1 = double psync rate (6 bpp) + int rate; // 0 = normal psync rate (3 bpp), 1 = double psync rate (6 bpp), 2 = sub-sample (even), 3=sub-sample(odd) } config_t; +static const char *rate_names[] = { + "Normal (3bpp)", + "Double (6ppp)", + "Half-Even (3bpp)", + "Half-Odd (3bpp)" +}; + // Current calibration state for mode 0..6 static config_t default_config; @@ -60,7 +67,7 @@ static int cpld_version; static int supports_delay; // Indicated the CPLD supports the rate parameter -static int supports_rate; +static int supports_rate; // 0 = no, 1 = 1-bit rate param, 2 = 1-bit rate param // ============================================================= // Param definitions for OSD @@ -78,7 +85,7 @@ enum { HALF, DIVIDER, DELAY, - SIXBIT + RATE }; static param_t params[] = { @@ -92,7 +99,7 @@ static param_t params[] = { { HALF, "Half", 0, 1, 1 }, { DIVIDER, "Divider", 6, 8, 2 }, { DELAY, "Delay", 0, 15, 1 }, - { SIXBIT, "Six bits", 0, 1, 1 }, + { RATE, "Sample Mode", 0, 3, 1 }, { -1, NULL, 0, 0, 1 } }; @@ -122,7 +129,7 @@ static void write_config(config_t *config) { } if (supports_rate) { sp |= (config->rate << scan_len); - scan_len += 1; + scan_len += supports_rate; // 1 or 2 depending on the CPLD version } for (int i = 0; i < scan_len; i++) { RPI_SetGpioValue(SP_DATA_PIN, sp & 1); @@ -209,9 +216,16 @@ static void cpld_init(int version) { if (!supports_delay) { params[DELAY].key = -1; } - supports_rate = ((cpld_version >> VERSION_MAJOR_BIT) & 0x0F) >= 3; - if (!supports_rate) { - params[SIXBIT].key = -1; + + if (((cpld_version >> VERSION_MAJOR_BIT) & 0x0F) >= 4) { + supports_rate = 2; + params[RATE].max = 3; + } else if (((cpld_version >> VERSION_MAJOR_BIT) & 0x0F) >= 3) { + supports_rate = 1; + params[RATE].max = 1; + } else { + supports_rate = 0; + params[RATE].key = -1; } for (int i = 0; i < NUM_OFFSETS; i++) { default_config.sp_offset[i] = 0; @@ -420,7 +434,7 @@ static void cpld_update_capture_info(capture_info_t *capinfo) { // Update the capture info stucture, if one was passed in if (capinfo) { // Update the sample width - capinfo->sample_width = config->rate; + capinfo->sample_width = (config->rate == 1); // 1 = 6bpp, everything else 3bpp // Update the line capture function if (!mode7) { if (capinfo->bpp == 8) { @@ -496,12 +510,19 @@ static int cpld_get_value(int num) { return config->divider; case DELAY: return config->full_px_delay; - case SIXBIT: + case RATE: return config->rate; } return 0; } +static const char *cpld_get_value_string(int num) { + if (num == RATE) { + return rate_names[config->rate]; + } + return NULL; +} + static void cpld_set_value(int num, int value) { switch (num) { case ALL_OFFSETS: @@ -540,7 +561,7 @@ static void cpld_set_value(int num, int value) { case DELAY: config->full_px_delay = value; break; - case SIXBIT: + case RATE: config->rate = value; break; } @@ -592,6 +613,7 @@ cpld_t cpld_normal = { .update_capture_info = cpld_update_capture_info, .get_params = cpld_get_params, .get_value = cpld_get_value, + .get_value_string = cpld_get_value_string, .set_value = cpld_set_value, .show_cal_summary = cpld_show_cal_summary, .show_cal_details = cpld_show_cal_details, diff --git a/src/osd.c b/src/osd.c index bdd884d2..da2c717c 100644 --- a/src/osd.c +++ b/src/osd.c @@ -602,6 +602,11 @@ static const char *get_param_string(param_menu_item_t *param_item) { if (value_str) { return value_str; } + } else { + const char *value_str = cpld->get_value_string(param->key); + if (value_str) { + return value_str; + } } if (is_boolean_param(param_item)) { return value ? "On" : "Off"; diff --git a/src/scripts/cmdline.txt b/src/scripts/cmdline.txt index af0cd49f..53dceaf3 100644 --- a/src/scripts/cmdline.txt +++ b/src/scripts/cmdline.txt @@ -198,7 +198,7 @@ # Important: All the properties must be on a single line, and no blank lines! # # Here's a good default for a Beeb or Master -sampling06=3 sampling7=0,2,2,2,2,2,2,0,8,5 info=1 palette=0 deinterlace=6 scanlines=0 mux=0 vsynctype=0 vsync=0 vlockmode=3 vlockline=5 nbuffers=0 debug=0 autoswitch=1 keymap=123233 return=1 +sampling06=3 sampling7=0,2,2,2,2,2,2,0,8,5,3 geometry7=37,28,63,270,504,270,1,4,192000000,12288 info=1 palette=0 deinterlace=6 scanlines=0 mux=0 vsynctype=0 vsync=0 vlockmode=3 vlockline=5 nbuffers=0 debug=0 autoswitch=1 keymap=123233 return=1 # # Here's a example showing no oversampling in Mode 0..6 #sampling06=0,4,4,4,4,4,4,0,2 geometry06=37,28,80,256,640,256,1 info=1 palette=0 deinterlace=1 scanlines=0 mux=0 vsynctype=0 vsync=0 vlockmode=3 nbuffers=0 debug=1 autoswitch=1