summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-10-07 21:59:21 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2017-10-07 22:01:00 +0200
commitafbae177a16fafbd898925e874fc56d395756d3a (patch)
treef48a8a166d3f3b30cf58313755d469118786e739
parent26d18fd34830fc58af7e57dad6f83acb6a9209c8 (diff)
downloadrockbox-afbae177a16fafbd898925e874fc56d395756d3a.tar.gz
rockbox-afbae177a16fafbd898925e874fc56d395756d3a.zip
sonynwz: add api and debug entries for "acoustic" and "cue/rev" mode
We don't really know what those are supposed to do. They seem to change the volume curve but it is not very clear what is the intended purpose. Change-Id: I65f5d18aba139844c23df092277ba17ee8518f96
-rw-r--r--firmware/drivers/audio/nwzlinux-codec.c27
-rw-r--r--firmware/export/nwzlinux_codec.h7
-rw-r--r--firmware/target/hosted/sonynwz/debug-nwz.c57
3 files changed, 77 insertions, 14 deletions
diff --git a/firmware/drivers/audio/nwzlinux-codec.c b/firmware/drivers/audio/nwzlinux-codec.c
index 36ebaa8b79..7d730ce68b 100644
--- a/firmware/drivers/audio/nwzlinux-codec.c
+++ b/firmware/drivers/audio/nwzlinux-codec.c
@@ -277,6 +277,29 @@ static void hw_close(void)
277 close(fd_hw); 277 close(fd_hw);
278} 278}
279 279
280/* Acoustic and Cue/Rev control how the volume curve, but it is not clear
281 * what the intention of these modes are and the OF does not seem to use
282 * them by default */
283bool audiohw_acoustic_enabled(void)
284{
285 return alsa_controls_get_bool("CODEC Acoustic Switch");
286}
287
288void audiohw_enable_acoustic(bool en)
289{
290 alsa_controls_set_bool("CODEC Acoustic Switch", en);
291}
292
293bool audiohw_cuerev_enabled(void)
294{
295 return alsa_controls_get_bool("CODEC Cue/Rev Switch");
296}
297
298void audiohw_enable_cuerev(bool en)
299{
300 alsa_controls_set_bool("CODEC Cue/Rev Switch", en);
301}
302
280void audiohw_preinit(void) 303void audiohw_preinit(void)
281{ 304{
282 alsa_controls_init(); 305 alsa_controls_init();
@@ -287,8 +310,8 @@ void audiohw_preinit(void)
287 /* Acoustic and Cue/Rev control how the volume curve, but it is not clear 310 /* Acoustic and Cue/Rev control how the volume curve, but it is not clear
288 * what the intention of these modes are and the OF does not seem to use 311 * what the intention of these modes are and the OF does not seem to use
289 * them by default */ 312 * them by default */
290 alsa_controls_set_bool("CODEC Acoustic Switch", false); 313 audiohw_enable_acoustic(false);
291 alsa_controls_set_bool("CODEC Cue/Rev Switch", false); 314 audiohw_enable_cuerev(false);
292 /* not sure exactly what it means */ 315 /* not sure exactly what it means */
293 alsa_controls_set_enum("Playback Src Switch", "Music"); 316 alsa_controls_set_enum("Playback Src Switch", "Music");
294 /* use headphone output */ 317 /* use headphone output */
diff --git a/firmware/export/nwzlinux_codec.h b/firmware/export/nwzlinux_codec.h
index fbd424a22e..dae8cca76f 100644
--- a/firmware/export/nwzlinux_codec.h
+++ b/firmware/export/nwzlinux_codec.h
@@ -26,4 +26,11 @@
26/* Ranges from -100dB to 4dB */ 26/* Ranges from -100dB to 4dB */
27AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -100, 4, -10) 27AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -100, 4, -10)
28 28
29/* enable/disable Sony's "acoustic" mode */
30bool audiohw_acoustic_enabled(void);
31void audiohw_enable_acoustic(bool en);
32/* enable/disable Sony's "cuerev" mode */
33bool audiohw_cuerev_enabled(void);
34void audiohw_enable_cuerev(bool en);
35
29#endif /* __NWZLINUX_CODEC_H__ */ 36#endif /* __NWZLINUX_CODEC_H__ */
diff --git a/firmware/target/hosted/sonynwz/debug-nwz.c b/firmware/target/hosted/sonynwz/debug-nwz.c
index e9044beca9..0c0b494330 100644
--- a/firmware/target/hosted/sonynwz/debug-nwz.c
+++ b/firmware/target/hosted/sonynwz/debug-nwz.c
@@ -36,6 +36,7 @@
36#include <sys/types.h> 36#include <sys/types.h>
37#include <fcntl.h> 37#include <fcntl.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include "nwzlinux_codec.h"
39 40
40/* NOTE: some targets with touchscreen don't have the usual keypad, on those 41/* NOTE: some targets with touchscreen don't have the usual keypad, on those
41 * we use a mixture of rewind/forward/volume+/- to emulate it */ 42 * we use a mixture of rewind/forward/volume+/- to emulate it */
@@ -44,6 +45,8 @@
44#define ACT_OK 2 45#define ACT_OK 2
45#define ACT_PREV 3 46#define ACT_PREV 3
46#define ACT_NEXT 4 47#define ACT_NEXT 4
48#define ACT_DEC 5
49#define ACT_INC 6
47#define ACT_REPEAT 0x1000 50#define ACT_REPEAT 0x1000
48 51
49int xlate_button(int btn) 52int xlate_button(int btn)
@@ -58,13 +61,21 @@ int xlate_button(int btn)
58 case BUTTON_PLAY: 61 case BUTTON_PLAY:
59 return ACT_OK; 62 return ACT_OK;
60 case BUTTON_UP: 63 case BUTTON_UP:
61 case BUTTON_LEFT: 64#ifdef BUTTON_FF
62 case BUTTON_VOL_UP: 65 case BUTTON_FF:
66#endif
63 return ACT_PREV; 67 return ACT_PREV;
64 case BUTTON_DOWN:
65 case BUTTON_RIGHT: 68 case BUTTON_RIGHT:
66 case BUTTON_VOL_DOWN: 69 case BUTTON_VOL_UP:
70 return ACT_INC;
71 case BUTTON_DOWN:
72#ifdef BUTTON_FF
73 case BUTTON_REW:
74#endif
67 return ACT_NEXT; 75 return ACT_NEXT;
76 case BUTTON_LEFT:
77 case BUTTON_VOL_DOWN:
78 return ACT_DEC;
68 default: 79 default:
69 return ACT_NONE; 80 return ACT_NONE;
70 } 81 }
@@ -96,8 +107,6 @@ bool dbg_hw_info_adc(void)
96 int button = my_get_action(HZ / 25); 107 int button = my_get_action(HZ / 25);
97 switch(button) 108 switch(button)
98 { 109 {
99 case ACT_NEXT:
100 case ACT_PREV:
101 case ACT_OK: 110 case ACT_OK:
102 lcd_setfont(FONT_UI); 111 lcd_setfont(FONT_UI);
103 return true; 112 return true;
@@ -166,8 +175,6 @@ bool dbg_hw_info_power(void)
166 int button = my_get_action(HZ / 25); 175 int button = my_get_action(HZ / 25);
167 switch(button) 176 switch(button)
168 { 177 {
169 case ACT_NEXT:
170 case ACT_PREV:
171 case ACT_OK: 178 case ACT_OK:
172 lcd_setfont(FONT_UI); 179 lcd_setfont(FONT_UI);
173 return true; 180 return true;
@@ -335,6 +342,7 @@ bool dbg_hw_info_audio(void)
335{ 342{
336 lcd_setfont(FONT_SYSFIXED); 343 lcd_setfont(FONT_SYSFIXED);
337 int vol = 0; 344 int vol = 0;
345 enum { VOL, ACOUSTIC, CUEREV, NR_SETTINGS } setting = VOL;
338 346
339 while(1) 347 while(1)
340 { 348 {
@@ -342,12 +350,10 @@ bool dbg_hw_info_audio(void)
342 switch(btn) 350 switch(btn)
343 { 351 {
344 case ACT_PREV: 352 case ACT_PREV:
345 vol--; 353 setting = (setting + NR_SETTINGS - 1) % NR_SETTINGS;
346 pcm_alsa_set_digital_volume(vol);
347 break; 354 break;
348 case ACT_NEXT: 355 case ACT_NEXT:
349 vol++; 356 setting = (setting + 1) % NR_SETTINGS;
350 pcm_alsa_set_digital_volume(vol);
351 break; 357 break;
352 case ACT_OK: 358 case ACT_OK:
353 lcd_setfont(FONT_UI); 359 lcd_setfont(FONT_UI);
@@ -356,11 +362,38 @@ bool dbg_hw_info_audio(void)
356 lcd_setfont(FONT_UI); 362 lcd_setfont(FONT_UI);
357 return false; 363 return false;
358 } 364 }
365 if(btn == ACT_INC || btn == ACT_DEC)
366 {
367 bool inc = (btn == ACT_INC);
368 switch(setting)
369 {
370 case VOL:
371 vol += inc ? 1 : -1;
372 pcm_alsa_set_digital_volume(vol);
373 break;
374 case ACOUSTIC:
375 audiohw_enable_acoustic(!audiohw_acoustic_enabled());
376 break;
377 case CUEREV:
378 audiohw_enable_cuerev(!audiohw_cuerev_enabled());
379 break;
380 default:
381 break;
382 }
383 }
359 384
360 lcd_clear_display(); 385 lcd_clear_display();
361 int line = 0; 386 int line = 0;
387#define SEL_COL(item) lcd_set_foreground(item == setting ? LCD_RGBPACK(255, 0, 0) : LCD_WHITE);
362 388
389 SEL_COL(VOL)
363 lcd_putsf(0, line++, "vol: %d dB", vol); 390 lcd_putsf(0, line++, "vol: %d dB", vol);
391 SEL_COL(ACOUSTIC)
392 lcd_putsf(0, line++, "acoustic: %s", audiohw_acoustic_enabled() ? "on" : "off");
393 SEL_COL(CUEREV)
394 lcd_putsf(0, line++, "cue/rev: %s", audiohw_cuerev_enabled() ? "on" : "off");
395 lcd_set_foreground(LCD_WHITE);
396#undef SEL_COL
364 397
365 lcd_update(); 398 lcd_update();
366 yield(); 399 yield();