summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-11-03 23:36:36 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-11-03 23:36:36 +0000
commitc22b411731b0a743382d7d7146e8ab59172ac764 (patch)
treeb338bae2b270f819219ace242001f5872d1815db
parent51d962f99b997aaed509c24daf15e25f8069fc47 (diff)
downloadrockbox-c22b411731b0a743382d7d7146e8ab59172ac764.tar.gz
rockbox-c22b411731b0a743382d7d7146e8ab59172ac764.zip
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
-rw-r--r--apps/lang/english.lang5
-rw-r--r--apps/settings.c26
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_menu.c15
-rw-r--r--firmware/drivers/dac.c27
-rw-r--r--firmware/drivers/dac.h5
-rw-r--r--firmware/mpeg.c2
7 files changed, 72 insertions, 10 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 813955d3b0..a3d8a03858 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1762,3 +1762,8 @@ id: LANG_CAR_ADAPTER_MODE
1762desc: Displayed for setting car adapter mode to on/off 1762desc: Displayed for setting car adapter mode to on/off
1763eng: "Car Adapter Mode" 1763eng: "Car Adapter Mode"
1764new: 1764new:
1765
1766id: LANG_LINE_IN
1767desc: in settings_menu
1768eng: "Line In"
1769new:
diff --git a/apps/settings.c b/apps/settings.c
index 9b8f1b35e1..429366d8ed 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -58,11 +58,13 @@
58#include "sprintf.h" 58#include "sprintf.h"
59#include "keyboard.h" 59#include "keyboard.h"
60#include "version.h" 60#include "version.h"
61 61#ifdef HAVE_MAS3507D
62#include "dac.h"
63#endif
62struct user_settings global_settings; 64struct user_settings global_settings;
63char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ 65char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
64 66
65#define CONFIG_BLOCK_VERSION 7 67#define CONFIG_BLOCK_VERSION 8
66#define CONFIG_BLOCK_SIZE 512 68#define CONFIG_BLOCK_SIZE 512
67#define RTC_BLOCK_SIZE 44 69#define RTC_BLOCK_SIZE 44
68 70
@@ -134,6 +136,7 @@ Rest of config block, only saved to disk:
1340xAE fade on pause/unpause/stop setting (bit 0) 1360xAE fade on pause/unpause/stop setting (bit 0)
135 caption backlight (bit 1) 137 caption backlight (bit 1)
136 car adapter mode (bit 2) 138 car adapter mode (bit 2)
139 line_in (Player only) (bit 3)
1370xAF [available/unused] 1400xAF [available/unused]
1380xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7) 1410xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7)
1390xB1 peak meter release step size, peak_meter_dbfs (bit 7) 1420xB1 peak meter release step size, peak_meter_dbfs (bit 7)
@@ -405,7 +408,8 @@ int settings_save( void )
405 config_block[0xae] = (unsigned char) 408 config_block[0xae] = (unsigned char)
406 ((global_settings.fade_on_stop & 1) | 409 ((global_settings.fade_on_stop & 1) |
407 ((global_settings.caption_backlight & 1) << 1) | 410 ((global_settings.caption_backlight & 1) << 1) |
408 ((global_settings.car_adapter_mode & 1) << 2)); 411 ((global_settings.car_adapter_mode & 1) << 2) |
412 ((global_settings.line_in & 1) << 3));
409 config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold | 413 config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold |
410 (global_settings.peak_meter_performance ? 0x80 : 0); 414 (global_settings.peak_meter_performance ? 0x80 : 0);
411 config_block[0xb1] = global_settings.peak_meter_release | 415 config_block[0xb1] = global_settings.peak_meter_release |
@@ -490,7 +494,9 @@ void settings_apply(void)
490 backlight_set_timeout(global_settings.backlight_timeout); 494 backlight_set_timeout(global_settings.backlight_timeout);
491 backlight_set_on_when_charging(global_settings.backlight_on_when_charging); 495 backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
492 ata_spindown(global_settings.disk_spindown); 496 ata_spindown(global_settings.disk_spindown);
493 497#ifdef HAVE_MAS3507D
498 dac_line_in(global_settings.line_in);
499#endif
494#ifdef HAVE_ATA_POWER_OFF 500#ifdef HAVE_ATA_POWER_OFF
495 ata_poweroff(global_settings.disk_poweroff); 501 ata_poweroff(global_settings.disk_poweroff);
496#endif 502#endif
@@ -690,6 +696,7 @@ void settings_load(void)
690 global_settings.fade_on_stop = config_block[0xae] & 1; 696 global_settings.fade_on_stop = config_block[0xae] & 1;
691 global_settings.caption_backlight = (config_block[0xae] >> 1) & 1; 697 global_settings.caption_backlight = (config_block[0xae] >> 1) & 1;
692 global_settings.car_adapter_mode = (config_block[0xae] >> 2) & 1; 698 global_settings.car_adapter_mode = (config_block[0xae] >> 2) & 1;
699 global_settings.line_in = (config_block[0xae] >> 3) & 1;
693 } 700 }
694 701
695 if(config_block[0xb0] != 0xff) { 702 if(config_block[0xb0] != 0xff) {
@@ -1059,6 +1066,12 @@ bool settings_load_config(char* file)
1059 "9","10","15","30","45","60"}; 1066 "9","10","15","30","45","60"};
1060 set_cfg_option(&global_settings.poweroff, value, options, 15); 1067 set_cfg_option(&global_settings.poweroff, value, options, 15);
1061 } 1068 }
1069#ifdef HAVE_MAS3507D
1070 else if (!strcasecmp(name, "line in")){
1071 set_cfg_bool(&global_settings.line_in, value);
1072 dac_line_in(global_settings.line_in);
1073 }
1074#endif
1062 else if (!strcasecmp(name, "battery capacity")) 1075 else if (!strcasecmp(name, "battery capacity"))
1063 set_cfg_int(&global_settings.battery_capacity, value, 1076 set_cfg_int(&global_settings.battery_capacity, value,
1064 1500, BATTERY_CAPACITY_MAX); 1077 1500, BATTERY_CAPACITY_MAX);
@@ -1341,6 +1354,10 @@ bool settings_save_config(void)
1341 fprintf(fd, "car adapter mode: %s\r\n", 1354 fprintf(fd, "car adapter mode: %s\r\n",
1342 boolopt[global_settings.car_adapter_mode]); 1355 boolopt[global_settings.car_adapter_mode]);
1343 1356
1357#ifdef HAVE_MAS3507D
1358 fprintf(fd, "line in: %s\r\n", boolopt[global_settings.line_in]);
1359#endif
1360
1344#ifdef HAVE_MAS3587F 1361#ifdef HAVE_MAS3587F
1345 fprintf(fd, "#\r\n# Recording\r\n#\r\n"); 1362 fprintf(fd, "#\r\n# Recording\r\n#\r\n");
1346 fprintf(fd, "rec quality: %d\r\n", global_settings.rec_quality); 1363 fprintf(fd, "rec quality: %d\r\n", global_settings.rec_quality);
@@ -1472,6 +1489,7 @@ void settings_reset(void) {
1472 global_settings.max_files_in_playlist = 10000; 1489 global_settings.max_files_in_playlist = 10000;
1473 global_settings.show_icons = true; 1490 global_settings.show_icons = true;
1474 global_settings.recursive_dir_insert = RECURSE_OFF; 1491 global_settings.recursive_dir_insert = RECURSE_OFF;
1492 global_settings.line_in = false;
1475} 1493}
1476 1494
1477bool set_bool(char* string, bool* variable ) 1495bool set_bool(char* string, bool* variable )
diff --git a/apps/settings.h b/apps/settings.h
index 635834cac0..93516d86cf 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -171,6 +171,8 @@ struct user_settings
171 int max_files_in_playlist; /* Max entries in playlist */ 171 int max_files_in_playlist; /* Max entries in playlist */
172 bool show_icons; /* 0=hide 1=show */ 172 bool show_icons; /* 0=hide 1=show */
173 int recursive_dir_insert; /* should directories be inserted recursively */ 173 int recursive_dir_insert; /* should directories be inserted recursively */
174
175 bool line_in; /* false=off, true=active */
174}; 176};
175 177
176enum optiontype { INT, BOOL }; 178enum optiontype { INT, BOOL };
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 7af267389a..d6fe1c6316 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -43,6 +43,9 @@
43#include "peakmeter.h" 43#include "peakmeter.h"
44#endif 44#endif
45#include "lang.h" 45#include "lang.h"
46#ifdef HAVE_MAS3507D
47#include "dac.h"
48#endif
46 49
47static bool car_adapter_mode(void) 50static bool car_adapter_mode(void)
48{ 51{
@@ -630,6 +633,15 @@ static bool spindown(void)
630 ata_spindown, 1, 3, 254 ); 633 ata_spindown, 1, 3, 254 );
631} 634}
632 635
636#ifdef HAVE_MAS3507D
637static bool line_in(void)
638{
639 bool rc = set_bool(str(LANG_LINE_IN), &global_settings.line_in);
640 dac_line_in(global_settings.line_in);
641 return rc;
642}
643#endif
644
633#ifdef HAVE_ATA_POWER_OFF 645#ifdef HAVE_ATA_POWER_OFF
634static bool poweroff(void) 646static bool poweroff(void)
635{ 647{
@@ -893,6 +905,9 @@ static bool system_settings_menu(void)
893 905
894 struct menu_items items[] = { 906 struct menu_items items[] = {
895 { str(LANG_SPINDOWN), spindown }, 907 { str(LANG_SPINDOWN), spindown },
908#ifdef HAVE_MAS3507D
909 { str(LANG_LINE_IN), line_in },
910#endif
896#ifdef HAVE_ATA_POWER_OFF 911#ifdef HAVE_ATA_POWER_OFF
897 { str(LANG_POWEROFF), poweroff }, 912 { str(LANG_POWEROFF), poweroff },
898#endif 913#endif
diff --git a/firmware/drivers/dac.c b/firmware/drivers/dac.c
index c8a5414611..4212b322f0 100644
--- a/firmware/drivers/dac.c
+++ b/firmware/drivers/dac.c
@@ -24,6 +24,10 @@
24 24
25#ifdef HAVE_DAC3550A 25#ifdef HAVE_DAC3550A
26 26
27static bool line_in_enabled = false;
28static bool dac_enabled = false;
29
30
27int dac_volume(unsigned int left, unsigned int right, bool deemph) 31int dac_volume(unsigned int left, unsigned int right, bool deemph)
28{ 32{
29 int ret = 0; 33 int ret = 0;
@@ -54,12 +58,16 @@ int dac_volume(unsigned int left, unsigned int right, bool deemph)
54** Bit6: 0 = 3V 1 = 5V 58** Bit6: 0 = 3V 1 = 5V
55** Bit5: 0 = normal 1 = low power 59** Bit5: 0 = normal 1 = low power
56** Bit4: 0 = AUX2 off 1 = AUX2 on 60** Bit4: 0 = AUX2 off 1 = AUX2 on
57** Bit3: 0 = AUX1 off 1 = AUX2 on 61** Bit3: 0 = AUX1 off 1 = AUX1 on
58** Bit2: 0 = DAC off 1 = DAC on 62** Bit2: 0 = DAC off 1 = DAC on
59** Bit1: 0 = stereo 1 = mono 63** Bit1: 0 = stereo 1 = mono
60** Bit0: 0 = normal right amp 1 = inverted right amp 64** Bit0: 0 = normal right amp 1 = inverted right amp
61******************************************************************/ 65******************************************************************/
62int dac_config(int value) 66/* dac_config is called once to initialize it. we will apply
67 our static settings because of the init flow.
68 dac_init -> dac_line_in -> mpeg_init -> dac_config
69*/
70static int dac_config(void)
63{ 71{
64 int ret = 0; 72 int ret = 0;
65 unsigned char buf[2]; 73 unsigned char buf[2];
@@ -67,7 +75,8 @@ int dac_config(int value)
67 i2c_begin(); 75 i2c_begin();
68 76
69 buf[0] = DAC_REG_WRITE | DAC_GCFG; 77 buf[0] = DAC_REG_WRITE | DAC_GCFG;
70 buf[1] = value; 78 buf[1] = (dac_enabled ? 0x04 : 0) |
79 (line_in_enabled ? 0x08 : 0);
71 80
72 /* send write command */ 81 /* send write command */
73 if (i2c_write(DAC_DEV_WRITE,buf,2)) 82 if (i2c_write(DAC_DEV_WRITE,buf,2))
@@ -79,6 +88,18 @@ int dac_config(int value)
79 return ret; 88 return ret;
80} 89}
81 90
91void dac_enable(bool enable)
92{
93 dac_enabled = enable;
94 dac_config();
95}
96
97void dac_line_in(bool enable)
98{
99 line_in_enabled = enable;
100 dac_config();
101}
102
82void dac_init(void) 103void dac_init(void)
83{ 104{
84 unsigned char buf[2]; 105 unsigned char buf[2];
diff --git a/firmware/drivers/dac.h b/firmware/drivers/dac.h
index ef5e4e992d..dc953c1420 100644
--- a/firmware/drivers/dac.h
+++ b/firmware/drivers/dac.h
@@ -36,8 +36,9 @@
36#define DAC_AVOL 2 36#define DAC_AVOL 2
37#define DAC_GCFG 3 37#define DAC_GCFG 3
38 38
39extern int dac_volume(unsigned int left, unsigned int right, bool deemph); 39extern int dac_volume(unsigned int left, unsigned int right, bool deemph);
40extern int dac_config(int value); 40extern void dac_enable(bool enable);
41extern void dac_line_in(bool enable);
41extern void dac_init(void); 42extern void dac_init(void);
42 43
43#endif 44#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 24b3a68008..ef6972f3e4 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -3212,7 +3212,7 @@ void mpeg_init(int volume, int bass, int treble, int balance, int loudness,
3212 mas_poll_start(1); 3212 mas_poll_start(1);
3213 3213
3214 mas_writereg(MAS_REG_KPRESCALE, 0xe9400); 3214 mas_writereg(MAS_REG_KPRESCALE, 0xe9400);
3215 dac_config(0x04); /* DAC on, all else off */ 3215 dac_enable(true);
3216 3216
3217 mpeg_sound_channel_config(channel_config); 3217 mpeg_sound_channel_config(channel_config);
3218#endif 3218#endif