Patch #798050 by Leslie Donaldson, activates Line In on Player models

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4008 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2003-11-03 23:36:36 +00:00
parent 51d962f99b
commit c22b411731
7 changed files with 72 additions and 10 deletions

View File

@ -1762,3 +1762,8 @@ id: LANG_CAR_ADAPTER_MODE
desc: Displayed for setting car adapter mode to on/off
eng: "Car Adapter Mode"
new:
id: LANG_LINE_IN
desc: in settings_menu
eng: "Line In"
new:

View File

@ -58,11 +58,13 @@
#include "sprintf.h"
#include "keyboard.h"
#include "version.h"
#ifdef HAVE_MAS3507D
#include "dac.h"
#endif
struct user_settings global_settings;
char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
#define CONFIG_BLOCK_VERSION 7
#define CONFIG_BLOCK_VERSION 8
#define CONFIG_BLOCK_SIZE 512
#define RTC_BLOCK_SIZE 44
@ -134,6 +136,7 @@ Rest of config block, only saved to disk:
0xAE fade on pause/unpause/stop setting (bit 0)
caption backlight (bit 1)
car adapter mode (bit 2)
line_in (Player only) (bit 3)
0xAF [available/unused]
0xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7)
0xB1 peak meter release step size, peak_meter_dbfs (bit 7)
@ -405,7 +408,8 @@ int settings_save( void )
config_block[0xae] = (unsigned char)
((global_settings.fade_on_stop & 1) |
((global_settings.caption_backlight & 1) << 1) |
((global_settings.car_adapter_mode & 1) << 2));
((global_settings.car_adapter_mode & 1) << 2) |
((global_settings.line_in & 1) << 3));
config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold |
(global_settings.peak_meter_performance ? 0x80 : 0);
config_block[0xb1] = global_settings.peak_meter_release |
@ -490,7 +494,9 @@ void settings_apply(void)
backlight_set_timeout(global_settings.backlight_timeout);
backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
ata_spindown(global_settings.disk_spindown);
#ifdef HAVE_MAS3507D
dac_line_in(global_settings.line_in);
#endif
#ifdef HAVE_ATA_POWER_OFF
ata_poweroff(global_settings.disk_poweroff);
#endif
@ -690,6 +696,7 @@ void settings_load(void)
global_settings.fade_on_stop = config_block[0xae] & 1;
global_settings.caption_backlight = (config_block[0xae] >> 1) & 1;
global_settings.car_adapter_mode = (config_block[0xae] >> 2) & 1;
global_settings.line_in = (config_block[0xae] >> 3) & 1;
}
if(config_block[0xb0] != 0xff) {
@ -1059,6 +1066,12 @@ bool settings_load_config(char* file)
"9","10","15","30","45","60"};
set_cfg_option(&global_settings.poweroff, value, options, 15);
}
#ifdef HAVE_MAS3507D
else if (!strcasecmp(name, "line in")){
set_cfg_bool(&global_settings.line_in, value);
dac_line_in(global_settings.line_in);
}
#endif
else if (!strcasecmp(name, "battery capacity"))
set_cfg_int(&global_settings.battery_capacity, value,
1500, BATTERY_CAPACITY_MAX);
@ -1341,6 +1354,10 @@ bool settings_save_config(void)
fprintf(fd, "car adapter mode: %s\r\n",
boolopt[global_settings.car_adapter_mode]);
#ifdef HAVE_MAS3507D
fprintf(fd, "line in: %s\r\n", boolopt[global_settings.line_in]);
#endif
#ifdef HAVE_MAS3587F
fprintf(fd, "#\r\n# Recording\r\n#\r\n");
fprintf(fd, "rec quality: %d\r\n", global_settings.rec_quality);
@ -1472,6 +1489,7 @@ void settings_reset(void) {
global_settings.max_files_in_playlist = 10000;
global_settings.show_icons = true;
global_settings.recursive_dir_insert = RECURSE_OFF;
global_settings.line_in = false;
}
bool set_bool(char* string, bool* variable )

View File

@ -171,6 +171,8 @@ struct user_settings
int max_files_in_playlist; /* Max entries in playlist */
bool show_icons; /* 0=hide 1=show */
int recursive_dir_insert; /* should directories be inserted recursively */
bool line_in; /* false=off, true=active */
};
enum optiontype { INT, BOOL };

View File

@ -43,6 +43,9 @@
#include "peakmeter.h"
#endif
#include "lang.h"
#ifdef HAVE_MAS3507D
#include "dac.h"
#endif
static bool car_adapter_mode(void)
{
@ -630,6 +633,15 @@ static bool spindown(void)
ata_spindown, 1, 3, 254 );
}
#ifdef HAVE_MAS3507D
static bool line_in(void)
{
bool rc = set_bool(str(LANG_LINE_IN), &global_settings.line_in);
dac_line_in(global_settings.line_in);
return rc;
}
#endif
#ifdef HAVE_ATA_POWER_OFF
static bool poweroff(void)
{
@ -893,6 +905,9 @@ static bool system_settings_menu(void)
struct menu_items items[] = {
{ str(LANG_SPINDOWN), spindown },
#ifdef HAVE_MAS3507D
{ str(LANG_LINE_IN), line_in },
#endif
#ifdef HAVE_ATA_POWER_OFF
{ str(LANG_POWEROFF), poweroff },
#endif

View File

@ -24,6 +24,10 @@
#ifdef HAVE_DAC3550A
static bool line_in_enabled = false;
static bool dac_enabled = false;
int dac_volume(unsigned int left, unsigned int right, bool deemph)
{
int ret = 0;
@ -54,12 +58,16 @@ int dac_volume(unsigned int left, unsigned int right, bool deemph)
** Bit6: 0 = 3V 1 = 5V
** Bit5: 0 = normal 1 = low power
** Bit4: 0 = AUX2 off 1 = AUX2 on
** Bit3: 0 = AUX1 off 1 = AUX2 on
** Bit3: 0 = AUX1 off 1 = AUX1 on
** Bit2: 0 = DAC off 1 = DAC on
** Bit1: 0 = stereo 1 = mono
** Bit0: 0 = normal right amp 1 = inverted right amp
******************************************************************/
int dac_config(int value)
/* dac_config is called once to initialize it. we will apply
our static settings because of the init flow.
dac_init -> dac_line_in -> mpeg_init -> dac_config
*/
static int dac_config(void)
{
int ret = 0;
unsigned char buf[2];
@ -67,7 +75,8 @@ int dac_config(int value)
i2c_begin();
buf[0] = DAC_REG_WRITE | DAC_GCFG;
buf[1] = value;
buf[1] = (dac_enabled ? 0x04 : 0) |
(line_in_enabled ? 0x08 : 0);
/* send write command */
if (i2c_write(DAC_DEV_WRITE,buf,2))
@ -79,6 +88,18 @@ int dac_config(int value)
return ret;
}
void dac_enable(bool enable)
{
dac_enabled = enable;
dac_config();
}
void dac_line_in(bool enable)
{
line_in_enabled = enable;
dac_config();
}
void dac_init(void)
{
unsigned char buf[2];

View File

@ -36,8 +36,9 @@
#define DAC_AVOL 2
#define DAC_GCFG 3
extern int dac_volume(unsigned int left, unsigned int right, bool deemph);
extern int dac_config(int value);
extern int dac_volume(unsigned int left, unsigned int right, bool deemph);
extern void dac_enable(bool enable);
extern void dac_line_in(bool enable);
extern void dac_init(void);
#endif

View File

@ -3212,7 +3212,7 @@ void mpeg_init(int volume, int bass, int treble, int balance, int loudness,
mas_poll_start(1);
mas_writereg(MAS_REG_KPRESCALE, 0xe9400);
dac_config(0x04); /* DAC on, all else off */
dac_enable(true);
mpeg_sound_channel_config(channel_config);
#endif