diff --git a/src/cpld.h b/src/cpld.h index ca693eb6..962e5d3a 100644 --- a/src/cpld.h +++ b/src/cpld.h @@ -11,7 +11,8 @@ typedef struct { int key; - const char *name; + const char *label; + const char *property_name; int min; int max; int step; diff --git a/src/cpld_normal.c b/src/cpld_normal.c index c03c9fa6..4e72111b 100644 --- a/src/cpld_normal.c +++ b/src/cpld_normal.c @@ -100,18 +100,18 @@ enum { }; static param_t params[] = { - { ALL_OFFSETS, "All Offsets", 0, 0, 1 }, - { A_OFFSET, "A Offset", 0, 0, 1 }, - { B_OFFSET, "B Offset", 0, 0, 1 }, - { C_OFFSET, "C Offset", 0, 0, 1 }, - { D_OFFSET, "D Offset", 0, 0, 1 }, - { E_OFFSET, "E Offset", 0, 0, 1 }, - { F_OFFSET, "F Offset", 0, 0, 1 }, - { HALF, "Half", 0, 1, 1 }, - { DIVIDER, "Divider", 6, 8, 2 }, - { DELAY, "Delay", 0, 15, 1 }, - { RATE, "Sample Mode", 0, 3, 1 }, - { -1, NULL, 0, 0, 1 } + { ALL_OFFSETS, "All Offsets", "all_offsets", 0, 0, 1 }, + { A_OFFSET, "A Offset", "a_offset", 0, 0, 1 }, + { B_OFFSET, "B Offset", "b_offset", 0, 0, 1 }, + { C_OFFSET, "C Offset", "c_offset", 0, 0, 1 }, + { D_OFFSET, "D Offset", "d_offset", 0, 0, 1 }, + { E_OFFSET, "E Offset", "e_offset", 0, 0, 1 }, + { F_OFFSET, "F Offset", "f_offset", 0, 0, 1 }, + { HALF, "Half", "half", 0, 1, 1 }, + { DIVIDER, "Divider", "divider", 6, 8, 2 }, + { DELAY, "Delay", "delay", 0, 15, 1 }, + { RATE, "Sample Mode", "sample_mode", 0, 3, 1 }, + { -1, NULL, NULL, 0, 0, 1 } }; // ============================================================= diff --git a/src/geometry.c b/src/geometry.c index 1a6ea7cd..dc5cb3aa 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -26,21 +26,21 @@ static const char *sync_names[] = { }; static param_t params[] = { - { H_OFFSET, "H Capture Offset", 0, 512, 4 }, - { V_OFFSET, "V Capture Offset", 0, 512, 1 }, - { H_WIDTH, "H Capture Width", 250, 1920, 8 }, - { V_HEIGHT, "V Capture Height", 150, 1200, 1 }, - { FB_WIDTH, "FB Width", 100, 1920, 8 }, - { FB_HEIGHT, "FB Height", 100, 1200, 1 }, - { FB_HEIGHTX2, "FB Double Height", 0, 1, 1 }, - { FB_BPP, "FB Bits/Pixel", 4, 8, 4 }, - { CLOCK, "Clock Frequency", 1000000, 40000000, 1000 }, - { LINE_LEN, "Line Length", 100, 5000, 1 }, - { CLOCK_PPM, "Clock Tolerance", 0, 100000, 100 }, - { LINES_FRAME, "Lines per Frame", 250, 1200, 1 }, - { SYNC_TYPE, "Sync Type", 0,NUM_SYNC-1, 1 }, - { PX_SAMPLING, "Pixel Sampling", 0, NUM_PS-1, 1 }, - { -1, NULL, 0, 0, 0 } + { H_OFFSET, "H Capture Offset", "h_capture_offset", 0, 512, 4 }, + { V_OFFSET, "V Capture Offset", "v_capture_offset", 0, 512, 1 }, + { H_WIDTH, "H Capture Width", "h_capture_width", 250, 1920, 8 }, + { V_HEIGHT, "V Capture Height", "v_capture_height", 150, 1200, 1 }, + { FB_WIDTH, "FB Width", "fb_width", 100, 1920, 8 }, + { FB_HEIGHT, "FB Height", "fb_height", 100, 1200, 1 }, + { FB_HEIGHTX2, "FB Double Height", "fb_double_height", 0, 1, 1 }, + { FB_BPP, "FB Bits/Pixel", "fb_bits_pixel", 4, 8, 4 }, + { CLOCK, "Clock Frequency", "clock_frequency", 1000000, 40000000, 1000 }, + { LINE_LEN, "Line Length", "line_length", 100, 5000, 1 }, + { CLOCK_PPM, "Clock Tolerance", "clock_tolerance", 0, 100000, 100 }, + { LINES_FRAME, "Lines per Frame", "lines_per_frame", 250, 1200, 1 }, + { SYNC_TYPE, "Sync Type", "sync_type", 0,NUM_SYNC-1, 1 }, + { PX_SAMPLING, "Pixel Sampling", "pixel_sampling", 0, NUM_PS-1, 1 }, + { -1, NULL, NULL, 0, 0, 0 } }; typedef struct { diff --git a/src/osd.c b/src/osd.c index 7c14cbbf..3a395f62 100644 --- a/src/osd.c +++ b/src/osd.c @@ -165,28 +165,28 @@ enum { }; static param_t features[] = { - { F_AUTOSWITCH, "Auto Switching", 0, NUM_AUTOSWITCHES - 1, 1 }, - { F_RESOLUTION,"Output Resolution", 0, 0, 1 }, - { F_INTERPOLATION, "Interpolation", 0,NUM_INTERPOLATION - 1, 1 }, - { F_PROFILE, "Computer Profile", 0, 0, 1 }, - { F_SUBPROFILE, "Sub-Profile", 0, 0, 1 }, - { F_PALETTE, "Palette", 0, NUM_PALETTES - 1, 1 }, - { F_PALETTECONTROL, "Palette Control", 0, NUM_CONTROLS - 1, 1 }, - { F_DEINTERLACE,"Mode7 Deinterlace", 0, NUM_DEINTERLACES - 1, 1 }, - { F_SCANLINES, "Scanlines", 0, 1, 1 }, - { F_SCANLINESINT, "Scanline Level", 0, 15, 1 }, - { F_SCALING, "Scaling", 0, NUM_SCALING - 1, 1 }, - { F_MUX,"Input Mux (3 Bit)", 0, 1, 1 }, - { F_VSYNCTYPE, "V Sync Type", 0, NUM_VSYNCTYPES - 1, 1 }, - { F_VSYNC, "V Sync Indicator", 0, 1, 1 }, - { F_VLOCKMODE, "V Lock Mode", 0, 5, 1 }, - { F_VLOCKLINE, "V Lock Line",10, 190, 1 }, - { F_VLOCKADJ, "V Lock Adjust", 0, NUM_VLOCKADJ - 2, 1 }, //-2 so disables 260 mhz for now + { F_AUTOSWITCH, "Auto Switching", "auto_switching", 0, NUM_AUTOSWITCHES - 1, 1 }, + { F_RESOLUTION,"Output Resolution","output_resolution", 0, 0, 1 }, + { F_INTERPOLATION, "Interpolation", "interpolation", 0,NUM_INTERPOLATION - 1, 1 }, + { F_PROFILE, "Computer Profile", "computer_profile", 0, 0, 1 }, + { F_SUBPROFILE, "Sub-Profile", "sub-profile", 0, 0, 1 }, + { F_PALETTE, "Palette", "palette", 0, NUM_PALETTES - 1, 1 }, + { F_PALETTECONTROL, "Palette Control", "palette_control", 0, NUM_CONTROLS - 1, 1 }, + { F_DEINTERLACE,"Mode7 Deinterlace","mode7_deinterlace", 0, NUM_DEINTERLACES - 1, 1 }, + { F_SCANLINES, "Scanlines", "scanlines", 0, 1, 1 }, + { F_SCANLINESINT, "Scanline Level", "scanline_level", 0, 15, 1 }, + { F_SCALING, "Scaling", "scaling", 0, NUM_SCALING - 1, 1 }, + { F_MUX,"Input Mux (3 Bit)", "input_mux", 0, 1, 1 }, + { F_VSYNCTYPE, "V Sync Type", "vsync_type", 0, NUM_VSYNCTYPES - 1, 1 }, + { F_VSYNC, "V Sync Indicator", "vsync_indicator", 0, 1, 1 }, + { F_VLOCKMODE, "V Lock Mode", "vlock_mode", 0, 5, 1 }, + { F_VLOCKLINE, "V Lock Line", "vlock_line",10, 190, 1 }, + { F_VLOCKADJ, "V Lock Adjust", "vlock_adjust", 0, NUM_VLOCKADJ - 2, 1 }, //-2 so disables 260 mhz for now #ifdef MULTI_BUFFER - { F_NBUFFERS, "Num Buffers", 0, 3, 1 }, + { F_NBUFFERS, "Num Buffers", "num_buffers", 0, 3, 1 }, #endif - { F_DEBUG, "Debug", 0, 1, 1 }, - { -1, NULL, 0, 0, 0 } + { F_DEBUG, "Debug", "debug", 0, 1, 1 }, + { -1, NULL, NULL, 0, 0, 0 } }; // ============================================================= @@ -659,7 +659,7 @@ static const char *item_name(base_menu_item_t *item) { case I_FEATURE: case I_GEOMETRY: case I_PARAM: - return ((param_menu_item_t *)item)->param->name; + return ((param_menu_item_t *)item)->param->label; case I_INFO: return ((info_menu_item_t *)item)->name; case I_BACK: @@ -1255,104 +1255,68 @@ int save_profile(char *path, char *name, char *buffer, char *default_buffer, cha geometry_set_mode(1); cpld->set_mode(1); - - sprintf(pointer, "sampling7="); - pointer += strlen(pointer); + pointer += sprintf(pointer, "sampling7="); i = 0; - for(;;) { + param = cpld->get_params(); + while(param->key >= 0) { + pointer += sprintf(pointer, "%d,", cpld->get_value(param->key)); + i++; param = cpld->get_params() + i; - if (param->key < 0) { - break; - } - sprintf(pointer, "%d,", cpld->get_value(param->key)); - pointer += strlen(pointer); - i++; } - sprintf(pointer - 1, "\r\n"); - pointer += strlen(pointer); - - sprintf(pointer, "geometry7="); - pointer += strlen(pointer); + pointer += sprintf(pointer - 1, "\r\n") - 1; + pointer += sprintf(pointer, "geometry7="); i = 0; - for(;;) { - param = geometry_get_params() + i; - if (param->key < 0) { - break; - } - sprintf(pointer, "%d,", geometry_get_value(param->key)); - pointer += strlen(pointer); + param = geometry_get_params(); + while(param->key >= 0) { + pointer += sprintf(pointer, "%d,", geometry_get_value(param->key)); i++; + param = geometry_get_params() + i; } - sprintf(pointer - 1, "\r\n"); - pointer += strlen(pointer); - + pointer += sprintf(pointer - 1, "\r\n") - 1; } geometry_set_mode(0); cpld->set_mode(0); - sprintf(pointer, "sampling="); - pointer += strlen(pointer); + pointer += sprintf(pointer, "sampling="); i = 0; - for(;;) { + param = cpld->get_params(); + while(param->key >= 0) { + pointer += sprintf(pointer, "%d,", cpld->get_value(param->key)); + i++; param = cpld->get_params() + i; - if (param->key < 0) { - break; - } - sprintf(pointer, "%d,", cpld->get_value(param->key)); - pointer += strlen(pointer); - i++; } - sprintf(pointer - 1, "\r\n"); - pointer += strlen(pointer); - - sprintf(pointer, "geometry="); - pointer += strlen(pointer); + pointer += sprintf(pointer - 1, "\r\n") - 1; + pointer += sprintf(pointer, "geometry="); i = 0; - for(;;) { - param = geometry_get_params() + i; - if (param->key < 0) { - break; - } - sprintf(pointer, "%d,", geometry_get_value(param->key)); - pointer += strlen(pointer); + param = geometry_get_params(); + while(param->key >= 0) { + pointer += sprintf(pointer, "%d,", geometry_get_value(param->key)); i++; + param = geometry_get_params() + i; } - sprintf(pointer - 1, "\r\n"); - pointer += strlen(pointer); - + pointer += sprintf(pointer - 1, "\r\n") - 1; geometry_set_mode(current_mode7); cpld->set_mode(current_mode7); } i = 0; - for(;;) { - if (features[i].key < 0) { - break; - } + while (features[i].key >= 0) { if ((default_buffer != NULL && i != F_RESOLUTION && i != F_INTERPOLATION && i != F_PROFILE && i != F_SUBPROFILE && (i != F_AUTOSWITCH || sub_default_buffer == NULL)) || (default_buffer == NULL && i == F_AUTOSWITCH)) { - strcpy(param_string, features[i].name); - for(int j = 0; j< strlen(param_string); j++) { - param_string[j] = tolower(param_string[j]); - if (param_string[j] == ' ') { - param_string[j] = '_'; - } - } + strcpy(param_string, features[i].property_name); sprintf(pointer, "%s=%d", param_string, get_feature(i)); if (strstr(default_buffer, pointer) == NULL) { if (sub_default_buffer) { if (strstr(sub_default_buffer, pointer) == NULL) { log_info("Writing sub profile entry: %s", pointer); pointer += strlen(pointer); - sprintf(pointer, "\r\n"); - pointer += 2; + pointer += sprintf(pointer, "\r\n"); } } else { log_info("Writing profile entry: %s", pointer); pointer += strlen(pointer); - sprintf(pointer, "\r\n"); - pointer += 2; + pointer += sprintf(pointer, "\r\n"); } } } @@ -1387,7 +1351,7 @@ void process_single_profile(char *buffer) { break; } int val = atoi(prop2); - log_debug("cpld: %s = %d", param->name, val); + log_debug("cpld: %s = %d", param->label, val); cpld->set_value(param->key, val); prop2 = strtok(NULL, ","); i++; @@ -1406,7 +1370,7 @@ void process_single_profile(char *buffer) { break; } int val = atoi(prop2); - log_debug("geometry: %s = %d", param->name, val); + log_debug("geometry: %s = %d", param->label, val); geometry_set_value(param->key, val); prop2 = strtok(NULL, ","); i++; @@ -1419,18 +1383,9 @@ void process_single_profile(char *buffer) { cpld->set_mode(current_mode7); i = 0; - for(;;) { - if (features[i].key < 0) { - break; - } + while(features[i].key >= 0) { if (i != F_RESOLUTION && i != F_INTERPOLATION && i != F_PROFILE && i != F_SUBPROFILE) { - strcpy(param_string, features[i].name); - for(int j = 0; j< strlen(param_string); j++) { - param_string[j] = tolower(param_string[j]); - if (param_string[j] == ' ') { - param_string[j] = '_'; - } - } + strcpy(param_string, features[i].property_name); prop = get_prop(buffer, param_string); if (prop) { int val = atoi(prop); @@ -1510,23 +1465,23 @@ void get_autoswitch_geometry(char *buffer, int index) int val = atoi(prop2); if (i == CLOCK) { autoswitch_info[index].clock = val; - log_debug("autoswitch: %s = %d", param->name, val); + log_debug("autoswitch: %s = %d", param->label, val); } if (i == LINE_LEN) { autoswitch_info[index].line_len = val; - log_debug("autoswitch: %s = %d", param->name, val); + log_debug("autoswitch: %s = %d", param->label, val); } if (i == CLOCK_PPM) { autoswitch_info[index].clock_ppm = val; - log_debug("autoswitch: %s = %d", param->name, val); + log_debug("autoswitch: %s = %d", param->label, val); } if (i == LINES_FRAME) { autoswitch_info[index].lines_per_frame = val; - log_debug("autoswitch: %s = %d", param->name, val); + log_debug("autoswitch: %s = %d", param->label, val); } if (i == SYNC_TYPE) { autoswitch_info[index].sync_type = val; - log_debug("autoswitch: %s = %d", param->name, val); + log_debug("autoswitch: %s = %d", param->label, val); } prop2 = strtok(NULL, ","); i++; @@ -2197,19 +2152,19 @@ void osd_update(uint32_t *osd_base, int bytes_per_line) { uint32_t *map_ptr = double_size_map_4bpp + data * 3; *word_ptr &= 0x77777777; *word_ptr |= *map_ptr; - *(word_ptr + words_per_line) &= 0x77777777;; + *(word_ptr + words_per_line) &= 0x77777777; *(word_ptr + words_per_line) |= *map_ptr; word_ptr++; map_ptr++; *word_ptr &= 0x77777777; *word_ptr |= *map_ptr; - *(word_ptr + words_per_line) &= 0x77777777;; + *(word_ptr + words_per_line) &= 0x77777777; *(word_ptr + words_per_line) |= *map_ptr; word_ptr++; map_ptr++; *word_ptr &= 0x77777777; *word_ptr |= *map_ptr; - *(word_ptr + words_per_line) &= 0x77777777;; + *(word_ptr + words_per_line) &= 0x77777777; *(word_ptr + words_per_line) |= *map_ptr; word_ptr++; } else { @@ -2287,13 +2242,13 @@ void osd_update(uint32_t *osd_base, int bytes_per_line) { uint32_t *map_ptr = double_size_map8_4bpp + data * 2; *word_ptr &= 0x77777777; *word_ptr |= *map_ptr; - *(word_ptr + words_per_line) &= 0x77777777;; + *(word_ptr + words_per_line) &= 0x77777777; *(word_ptr + words_per_line) |= *map_ptr; word_ptr++; map_ptr++; *word_ptr &= 0x77777777; *word_ptr |= *map_ptr; - *(word_ptr + words_per_line) &= 0x77777777;; + *(word_ptr + words_per_line) &= 0x77777777; *(word_ptr + words_per_line) |= *map_ptr; word_ptr++; map_ptr++;