blob: f8ce4fd266a8b04583379271b77bf03a9534e36e [file] [log] [blame]
Jonathan Gordonb2e50902007-01-23 13:40:44 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Jonathan Gordon4e73b532007-02-13 00:32:17 +00008 * $Id$
Jonathan Gordonb2e50902007-01-23 13:40:44 +00009 *
10 * Copyright (C) 2007 Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordonb2e50902007-01-23 13:40:44 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __SETTINGSLIST_H
22#define __SETTINGSLIST_H
23#include <stdio.h>
24#include <stddef.h>
25#include <stdbool.h>
26#include <limits.h>
27#include "inttypes.h"
28
Jonathan Gordon0c337562007-01-24 03:14:07 +000029typedef int (*_isfunc_type)(void);
30
Jonathan Gordonb2e50902007-01-23 13:40:44 +000031union storage_type {
32 int int_;
33 unsigned int uint_;
34 bool bool_;
35 char *charptr;
36 unsigned char *ucharptr;
Jonathan Gordon0c337562007-01-24 03:14:07 +000037 _isfunc_type func;
Jonathan Gordonb2e50902007-01-23 13:40:44 +000038};
39/* the variable type for the setting */
40#define F_T_INT 1
41#define F_T_UINT 2
42#define F_T_BOOL 3
43#define F_T_CHARPTR 4
44#define F_T_UCHARPTR 5
45#define F_T_MASK 0x7
46
47struct sound_setting {
48 int setting; /* from the enum in firmware/sound.h */
49};
50#define F_T_SOUND 0x8 /* this variable uses the set_sound stuff, \
51 | with one of the above types (usually F_T_INT) \
52 These settings get the default from sound_default(setting); */
53struct bool_setting {
54 void (*option_callback)(bool);
55 int lang_yes;
56 int lang_no;
57};
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000058#define F_BOOL_SETTING (F_T_BOOL|0x10)
Jonathan Gordonb2e50902007-01-23 13:40:44 +000059#define F_RGB 0x20
60
Jonathan Gordon0c337562007-01-24 03:14:07 +000061struct filename_setting {
62 const char* prefix;
63 const char* suffix;
64 int max_len;
65};
66#define F_FILENAME 0x40
67
Jonathan Gordonb2e50902007-01-23 13:40:44 +000068struct int_setting {
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000069 void (*option_callback)(int);
70 int unit;
71 int min;
72 int max;
73 int step;
Nils Wallménius9b591832007-08-19 10:22:46 +000074 void (*formatter)(char*, size_t, int, const char*);
Jens Arnold09a78612007-11-26 23:10:20 +000075 int32_t (*get_talk_id)(int, int);
Jonathan Gordonb2e50902007-01-23 13:40:44 +000076};
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000077#define F_INT_SETTING 0x80
78
79struct choice_setting {
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000080 void (*option_callback)(int);
81 int count;
82 union {
Jens Arnoldd490f442007-11-25 17:36:21 +000083 const unsigned char **desc;
84 const int *talks;
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000085 };
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000086};
87#define F_CHOICE_SETTING 0x100
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000088#define F_CHOICETALKS 0x200 /* uses .talks in the above struct for the talks */
89 /* and cfg_vals for the strings to display */
Jens Arnoldd490f442007-11-25 17:36:21 +000090
91struct table_setting {
92 void (*option_callback)(int);
93 void (*formatter)(char*, size_t, int, const char*);
Jens Arnold09a78612007-11-26 23:10:20 +000094 int32_t (*get_talk_id)(int, int);
Jens Arnoldd490f442007-11-25 17:36:21 +000095 int unit;
96 int count;
97 const int * values;
98};
99#define F_TABLE_SETTING 0x2000
100#define F_ALLOW_ARBITRARY_VALS 0x4000
Jonathan Gordon0c337562007-01-24 03:14:07 +0000101/* these use the _isfunc_type type for the function */
102/* typedef int (*_isfunc_type)(void); */
103#define F_MIN_ISFUNC 0x100000 /* min(above) is function pointer to above type */
104#define F_MAX_ISFUNC 0x200000 /* max(above) is function pointer to above type */
105#define F_DEF_ISFUNC 0x400000 /* default_val is function pointer to above type */
106
Jonathan Gordon9adf0562007-05-29 04:39:11 +0000107#define F_THEMESETTING 0x0800000
108#define F_RECSETTING 0x1000000
Dan Everton5886efa2007-12-07 10:59:07 +0000109#define F_EQSETTING 0x2000000
Jonathan Gordonb8bc45d2007-12-24 22:35:31 +0000110#define F_SOUNDSETTING 0x4000000
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000111
Jens Arnoldd490f442007-11-25 17:36:21 +0000112#define F_NVRAM_BYTES_MASK 0xE0000 /*0-4 bytes can be stored */
113#define F_NVRAM_MASK_SHIFT 17
Jonathan Gordon07a7d472007-08-12 09:53:41 +0000114#define NVRAM_CONFIG_VERSION 4
Jonathan Gordonb2e50902007-01-23 13:40:44 +0000115/* Above define should be bumped if
116- a new NVRAM setting is added between 2 other NVRAM settings
117- number of bytes for a NVRAM setting is changed
118- a NVRAM setting is removed
119*/
Nils Wallménius12a957b2007-09-15 17:29:15 +0000120#define F_TEMPVAR 0x0400 /* used if the setting should be set using a temp var */
Jonathan Gordon91ccc012007-11-05 13:15:35 +0000121#define F_PADTITLE 0x800 /* pad the title with spaces to force it to scroll */
Nils Wallménius12a957b2007-09-15 17:29:15 +0000122#define F_NO_WRAP 0x1000 /* used if the list should not wrap */
Jonathan Gordon0c337562007-01-24 03:14:07 +0000123
Jonathan Gordonb2e50902007-01-23 13:40:44 +0000124struct settings_list {
Jonathan Gordonb8bc45d2007-12-24 22:35:31 +0000125 uint32_t flags; /* ____ _SER TFFF NNN_ _ATW PTVC IFRB STTT */
Jonathan Gordonb2e50902007-01-23 13:40:44 +0000126 void *setting;
Jonathan Gordon4ca8a432007-01-26 05:45:06 +0000127 int lang_id; /* -1 for none */
Jonathan Gordonb2e50902007-01-23 13:40:44 +0000128 union storage_type default_val;
129 const char *cfg_name; /* this settings name in the cfg file */
130 const char *cfg_vals; /*comma seperated legal values, or NULL */
131 /* used with F_T_UCHARPTR this is the folder prefix */
132 union {
Jens Arnoldd490f442007-11-25 17:36:21 +0000133 const void *RESERVED; /* to stop compile errors, will be removed */
134 const struct sound_setting *sound_setting; /* use F_T_SOUND for this */
135 const struct bool_setting *bool_setting; /* F_BOOL_SETTING */
136 const struct filename_setting *filename_setting; /* use F_FILENAME */
137 const struct int_setting *int_setting; /* use F_INT_SETTING */
138 const struct choice_setting *choice_setting; /* F_CHOICE_SETTING */
139 const struct table_setting *table_setting; /* F_TABLE_SETTING */
Jonathan Gordonb2e50902007-01-23 13:40:44 +0000140 };
141};
142
143#ifndef PLUGIN
144/* not needed for plugins and just causes compile error,
145 possibly fix proberly later */
146extern const struct settings_list settings[];
147extern const int nb_settings;
148
149#endif
150
151#endif