mirror of
https://github.com/marqs85/ossc.git
synced 2024-12-27 11:30:11 +00:00
add name to profile struct
This commit is contained in:
parent
97247d1f33
commit
978ac04a43
2
ossc.qsf
2
ossc.qsf
@ -224,7 +224,7 @@ set_global_assignment -name ENABLE_SIGNALTAP OFF
|
|||||||
set_global_assignment -name USE_SIGNALTAP_FILE output_files/ossc_la.stp
|
set_global_assignment -name USE_SIGNALTAP_FILE output_files/ossc_la.stp
|
||||||
|
|
||||||
set_global_assignment -name FITTER_EFFORT "AUTO FIT"
|
set_global_assignment -name FITTER_EFFORT "AUTO FIT"
|
||||||
set_global_assignment -name SEED 16
|
set_global_assignment -name SEED 12
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -548,7 +548,7 @@ void program_mode()
|
|||||||
int load_profile() {
|
int load_profile() {
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = read_userdata(profile_sel_menu);
|
retval = read_userdata(profile_sel_menu, 0);
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
profile_sel = profile_sel_menu;
|
profile_sel = profile_sel_menu;
|
||||||
|
|
||||||
@ -681,8 +681,8 @@ int init_hw()
|
|||||||
memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap));
|
memcpy(rc_keymap, rc_keymap_default, sizeof(rc_keymap));
|
||||||
|
|
||||||
// Load initconfig and profile
|
// Load initconfig and profile
|
||||||
read_userdata(INIT_CONFIG_SLOT);
|
read_userdata(INIT_CONFIG_SLOT, 0);
|
||||||
read_userdata(profile_sel);
|
read_userdata(profile_sel, 0);
|
||||||
|
|
||||||
// Setup remote keymap
|
// Setup remote keymap
|
||||||
if (!(IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & PB1_BIT))
|
if (!(IORD_ALTERA_AVALON_PIO_DATA(PIO_1_BASE) & PB1_BIT))
|
||||||
@ -882,7 +882,7 @@ int main()
|
|||||||
// input->profile link is enabled
|
// input->profile link is enabled
|
||||||
if (profile_link && (profile_sel != input_profiles[target_input])) {
|
if (profile_link && (profile_sel != input_profiles[target_input])) {
|
||||||
profile_sel = input_profiles[target_input];
|
profile_sel = input_profiles[target_input];
|
||||||
read_userdata(profile_sel);
|
read_userdata(profile_sel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto_input_changed = 0;
|
auto_input_changed = 0;
|
||||||
|
@ -43,6 +43,7 @@ extern alt_u32 remote_code;
|
|||||||
extern alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
extern alt_u16 rc_keymap[REMOTE_MAX_KEYS];
|
||||||
extern alt_u8 vm_sel, profile_sel_menu, lt_sel, def_input, profile_link, lcd_bl_timeout;
|
extern alt_u8 vm_sel, profile_sel_menu, lt_sel, def_input, profile_link, lcd_bl_timeout;
|
||||||
extern alt_u8 auto_input, auto_av1_ypbpr, auto_av2_ypbpr, auto_av3_ypbpr;
|
extern alt_u8 auto_input, auto_av1_ypbpr, auto_av2_ypbpr, auto_av3_ypbpr;
|
||||||
|
extern char target_profile_name[PROFILE_NAME_LEN+1];
|
||||||
|
|
||||||
alt_u8 menu_active;
|
alt_u8 menu_active;
|
||||||
|
|
||||||
@ -84,10 +85,11 @@ static void lt_disp(alt_u8 v) { strncpy(menu_row2, lt_desc[v], LCD_ROW_LEN+1); }
|
|||||||
static void aud_db_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%d dB", ((alt_8)v-AUDIO_GAIN_0DB)); }
|
static void aud_db_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%d dB", ((alt_8)v-AUDIO_GAIN_0DB)); }
|
||||||
static void vm_display_name (alt_u8 v) { strncpy(menu_row2, video_modes[v].name, LCD_ROW_LEN+1); }
|
static void vm_display_name (alt_u8 v) { strncpy(menu_row2, video_modes[v].name, LCD_ROW_LEN+1); }
|
||||||
static void link_av_desc (avinput_t v) { strncpy(menu_row2, v == AV_LAST ? "No link" : avinput_str[v], LCD_ROW_LEN+1); }
|
static void link_av_desc (avinput_t v) { strncpy(menu_row2, v == AV_LAST ? "No link" : avinput_str[v], LCD_ROW_LEN+1); }
|
||||||
|
static void profile_disp(alt_u8 v) { read_userdata(v, 1); sniprintf(menu_row2, LCD_ROW_LEN+1, "%u: %s", v, (target_profile_name[0] == 0) ? "<empty>" : target_profile_name); }
|
||||||
//static void coarse_gain_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%u.%u", ((v*10)+50)/100, (((v*10)+50)%100)/10); }
|
//static void coarse_gain_disp(alt_u8 v) { sniprintf(menu_row2, LCD_ROW_LEN+1, "%u.%u", ((v*10)+50)/100, (((v*10)+50)%100)/10); }
|
||||||
|
|
||||||
static const arg_info_t vm_arg_info = {&vm_sel, VIDEO_MODES_CNT-1, vm_display_name};
|
static const arg_info_t vm_arg_info = {&vm_sel, VIDEO_MODES_CNT-1, vm_display_name};
|
||||||
static const arg_info_t profile_arg_info = {&profile_sel_menu, MAX_PROFILE, value_disp};
|
static const arg_info_t profile_arg_info = {&profile_sel_menu, MAX_PROFILE, profile_disp};
|
||||||
static const arg_info_t lt_arg_info = {<_sel, (sizeof(lt_desc)/sizeof(char*))-1, lt_disp};
|
static const arg_info_t lt_arg_info = {<_sel, (sizeof(lt_desc)/sizeof(char*))-1, lt_disp};
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,6 +42,8 @@ extern alt_u8 auto_input, auto_av1_ypbpr, auto_av2_ypbpr, auto_av3_ypbpr;
|
|||||||
extern SD_DEV sdcard_dev;
|
extern SD_DEV sdcard_dev;
|
||||||
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
extern char menu_row1[LCD_ROW_LEN+1], menu_row2[LCD_ROW_LEN+1];
|
||||||
|
|
||||||
|
char target_profile_name[PROFILE_NAME_LEN+1];
|
||||||
|
|
||||||
int write_userdata(alt_u8 entry)
|
int write_userdata(alt_u8 entry)
|
||||||
{
|
{
|
||||||
alt_u8 databuf[PAGESIZE];
|
alt_u8 databuf[PAGESIZE];
|
||||||
@ -85,6 +87,11 @@ int write_userdata(alt_u8 entry)
|
|||||||
((ude_profile*)databuf)->avc_data_len = sizeof(avconfig_t);
|
((ude_profile*)databuf)->avc_data_len = sizeof(avconfig_t);
|
||||||
((ude_profile*)databuf)->vm_data_len = vm_to_write;
|
((ude_profile*)databuf)->vm_data_len = vm_to_write;
|
||||||
|
|
||||||
|
if (target_profile_name[0] == 0)
|
||||||
|
sniprintf(target_profile_name, PROFILE_NAME_LEN+1, "<used>");
|
||||||
|
|
||||||
|
strncpy(((ude_profile*)databuf)->name, target_profile_name, PROFILE_NAME_LEN+1);
|
||||||
|
|
||||||
pageoffset = offsetof(ude_profile, avc);
|
pageoffset = offsetof(ude_profile, avc);
|
||||||
|
|
||||||
// assume that sizeof(avconfig_t) << PAGESIZE
|
// assume that sizeof(avconfig_t) << PAGESIZE
|
||||||
@ -110,7 +117,7 @@ int write_userdata(alt_u8 entry)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_userdata(alt_u8 entry)
|
int read_userdata(alt_u8 entry, int dry_run)
|
||||||
{
|
{
|
||||||
int retval, i;
|
int retval, i;
|
||||||
alt_u8 databuf[PAGESIZE];
|
alt_u8 databuf[PAGESIZE];
|
||||||
@ -118,6 +125,8 @@ int read_userdata(alt_u8 entry)
|
|||||||
alt_u16 pageoffset, dstoffset;
|
alt_u16 pageoffset, dstoffset;
|
||||||
alt_u8 pageno;
|
alt_u8 pageno;
|
||||||
|
|
||||||
|
target_profile_name[0] = 0;
|
||||||
|
|
||||||
if (entry > MAX_USERDATA_ENTRY) {
|
if (entry > MAX_USERDATA_ENTRY) {
|
||||||
printf("invalid entry\n");
|
printf("invalid entry\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -142,6 +151,9 @@ int read_userdata(alt_u8 entry)
|
|||||||
switch (((ude_hdr*)databuf)->type) {
|
switch (((ude_hdr*)databuf)->type) {
|
||||||
case UDE_INITCFG:
|
case UDE_INITCFG:
|
||||||
if (((ude_initcfg*)databuf)->data_len == sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile)) {
|
if (((ude_initcfg*)databuf)->data_len == sizeof(ude_initcfg) - offsetof(ude_initcfg, last_profile)) {
|
||||||
|
if (dry_run)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < sizeof(input_profiles)/sizeof(*input_profiles); ++i)
|
for (i = 0; i < sizeof(input_profiles)/sizeof(*input_profiles); ++i)
|
||||||
if (((ude_initcfg*)databuf)->last_profile[i] <= MAX_PROFILE)
|
if (((ude_initcfg*)databuf)->last_profile[i] <= MAX_PROFILE)
|
||||||
input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i];
|
input_profiles[i] = ((ude_initcfg*)databuf)->last_profile[i];
|
||||||
@ -163,6 +175,10 @@ int read_userdata(alt_u8 entry)
|
|||||||
break;
|
break;
|
||||||
case UDE_PROFILE:
|
case UDE_PROFILE:
|
||||||
if ((((ude_profile*)databuf)->avc_data_len == sizeof(avconfig_t)) && (((ude_profile*)databuf)->vm_data_len == VIDEO_MODES_SIZE)) {
|
if ((((ude_profile*)databuf)->avc_data_len == sizeof(avconfig_t)) && (((ude_profile*)databuf)->vm_data_len == VIDEO_MODES_SIZE)) {
|
||||||
|
strncpy(target_profile_name, ((ude_profile*)databuf)->name, PROFILE_NAME_LEN+1);
|
||||||
|
if (dry_run)
|
||||||
|
return 0;
|
||||||
|
|
||||||
vm_to_read = ((ude_profile*)databuf)->vm_data_len;
|
vm_to_read = ((ude_profile*)databuf)->vm_data_len;
|
||||||
|
|
||||||
pageno = 0;
|
pageno = 0;
|
||||||
@ -204,6 +220,7 @@ int read_userdata(alt_u8 entry)
|
|||||||
int import_userdata()
|
int import_userdata()
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
int n, entries_imported=0;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
alt_u8 databuf[SD_BLK_SIZE];
|
alt_u8 databuf[SD_BLK_SIZE];
|
||||||
ude_hdr header;
|
ude_hdr header;
|
||||||
@ -231,12 +248,8 @@ int import_userdata()
|
|||||||
usleep(WAITLOOP_SLEEP_US);
|
usleep(WAITLOOP_SLEEP_US);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(menu_row1, "Loading settings", LCD_ROW_LEN+1);
|
|
||||||
strncpy(menu_row2, "please wait...", LCD_ROW_LEN+1);
|
|
||||||
lcd_write_menu();
|
|
||||||
|
|
||||||
// Import the userdata
|
// Import the userdata
|
||||||
for (int n=0; n<=MAX_USERDATA_ENTRY; ++n) {
|
for (n=0; n<=MAX_USERDATA_ENTRY; ++n) {
|
||||||
retval = SD_Read(&sdcard_dev, &header, (512+n*SECTORSIZE)/SD_BLK_SIZE, 0, sizeof(header));
|
retval = SD_Read(&sdcard_dev, &header, (512+n*SECTORSIZE)/SD_BLK_SIZE, 0, sizeof(header));
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
printf("Failed to read SD card\n");
|
printf("Failed to read SD card\n");
|
||||||
@ -266,13 +279,20 @@ int import_userdata()
|
|||||||
printf("Copy from SD to flash failed (error %d)\n", retval);
|
printf("Copy from SD to flash failed (error %d)\n", retval);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entries_imported++;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPI_CS_High();
|
SPI_CS_High();
|
||||||
|
|
||||||
read_userdata(INIT_CONFIG_SLOT);
|
read_userdata(INIT_CONFIG_SLOT, 0);
|
||||||
profile_sel = input_profiles[target_input];
|
profile_sel = input_profiles[target_input];
|
||||||
read_userdata(profile_sel);
|
read_userdata(profile_sel, 0);
|
||||||
|
|
||||||
|
sniprintf(menu_row1, LCD_ROW_LEN+1, "%d entries", entries_imported);
|
||||||
|
strncpy(menu_row2, "imported", LCD_ROW_LEN+1);
|
||||||
|
lcd_write_menu();
|
||||||
|
usleep(1000000);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include "video_modes.h"
|
#include "video_modes.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
|
||||||
|
#define PROFILE_NAME_LEN 12
|
||||||
|
|
||||||
#define MAX_PROFILE (MAX_USERDATA_ENTRY-1)
|
#define MAX_PROFILE (MAX_USERDATA_ENTRY-1)
|
||||||
#define INIT_CONFIG_SLOT MAX_USERDATA_ENTRY
|
#define INIT_CONFIG_SLOT MAX_USERDATA_ENTRY
|
||||||
|
|
||||||
@ -62,6 +64,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ude_hdr hdr;
|
ude_hdr hdr;
|
||||||
|
char name[PROFILE_NAME_LEN+1];
|
||||||
alt_u16 avc_data_len;
|
alt_u16 avc_data_len;
|
||||||
alt_u16 vm_data_len;
|
alt_u16 vm_data_len;
|
||||||
avconfig_t avc;
|
avconfig_t avc;
|
||||||
@ -69,7 +72,7 @@ typedef struct {
|
|||||||
} __attribute__((packed, __may_alias__)) ude_profile;
|
} __attribute__((packed, __may_alias__)) ude_profile;
|
||||||
|
|
||||||
int write_userdata(alt_u8 entry);
|
int write_userdata(alt_u8 entry);
|
||||||
int read_userdata(alt_u8 entry);
|
int read_userdata(alt_u8 entry, int dry_run);
|
||||||
int import_userdata();
|
int import_userdata();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user