summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2017-10-01 16:13:54 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2017-10-01 17:23:43 +0200
commita82ebac53a23867452a62e3bd6c2516679ac95d8 (patch)
treea03b0986f141e882f12d66b0fc05825b2008e40b
parent50e93d56874dec894b81fa6fcfecc6d46525ee2a (diff)
downloadrockbox-a82ebac53a23867452a62e3bd6c2516679ac95d8.tar.gz
rockbox-a82ebac53a23867452a62e3bd6c2516679ac95d8.zip
sonynwza10/a20: enable pcm frequency selection
Change-Id: I335fcdbb652253e777d0d7406545d0d44d98f4f0
-rw-r--r--firmware/drivers/audio/nwzlinux-codec.c21
-rw-r--r--firmware/export/config/sonynwzlinux.h6
-rw-r--r--firmware/target/hosted/alsa-controls.c9
-rw-r--r--firmware/target/hosted/alsa-controls.h2
-rw-r--r--firmware/target/hosted/pcm-alsa.c4
5 files changed, 41 insertions, 1 deletions
diff --git a/firmware/drivers/audio/nwzlinux-codec.c b/firmware/drivers/audio/nwzlinux-codec.c
index aa0c7efcf8..36ebaa8b79 100644
--- a/firmware/drivers/audio/nwzlinux-codec.c
+++ b/firmware/drivers/audio/nwzlinux-codec.c
@@ -84,6 +84,15 @@ numid=4,iface=MIXER,name='Output Switch'
84 ; Item #2 'LineFixed' 84 ; Item #2 'LineFixed'
85 ; Item #3 'Speaker' 85 ; Item #3 'Speaker'
86 : values=0 86 : values=0
87numid=6,iface=MIXER,name='Sampling Rate'
88 ; type=ENUMERATED,access=rw------,values=1,items=6
89 ; Item #0 '44100'
90 ; Item #1 '48000'
91 ; Item #2 '88200'
92 ; Item #3 '96000'
93 ; Item #4 '176400'
94 ; Item #5 '192000'
95 : values=0
87*/ 96*/
88 97
89/* List of various codecs used by Sony */ 98/* List of various codecs used by Sony */
@@ -111,6 +120,8 @@ static int fd_noican;
111static int fd_hw; 120static int fd_hw;
112/* Codec */ 121/* Codec */
113static enum nwz_codec_t nwz_codec; 122static enum nwz_codec_t nwz_codec;
123/* does the code support setting the sample rate? */
124static bool has_sample_rate;
114 125
115static enum nwz_codec_t find_codec(void) 126static enum nwz_codec_t find_codec(void)
116{ 127{
@@ -284,6 +295,8 @@ void audiohw_preinit(void)
284 alsa_controls_set_enum("Output Switch", "Headphone"); 295 alsa_controls_set_enum("Output Switch", "Headphone");
285 /* unmute */ 296 /* unmute */
286 alsa_controls_set_bool("CODEC Mute Switch", false); 297 alsa_controls_set_bool("CODEC Mute Switch", false);
298 /* sample rate */
299 has_sample_rate = alsa_has_control("Sampling Rate");
287 300
288 /* init noican */ 301 /* init noican */
289 noican_init(); 302 noican_init();
@@ -381,5 +394,11 @@ void audiohw_close(void)
381 394
382void audiohw_set_frequency(int fsel) 395void audiohw_set_frequency(int fsel)
383{ 396{
384 (void) fsel; 397 if(has_sample_rate)
398 {
399 /* it's slightly annoying that Sony put the value in an enum with strings... */
400 char freq_str[16];
401 sprintf(freq_str, "%d", fsel);
402 alsa_controls_set_enum("Sampling Rate", freq_str);
403 }
385} 404}
diff --git a/firmware/export/config/sonynwzlinux.h b/firmware/export/config/sonynwzlinux.h
index f32c75c8b9..3ca0e014cb 100644
--- a/firmware/export/config/sonynwzlinux.h
+++ b/firmware/export/config/sonynwzlinux.h
@@ -65,6 +65,12 @@
65/* There is no hardware tone control */ 65/* There is no hardware tone control */
66#define HAVE_SW_TONE_CONTROLS 66#define HAVE_SW_TONE_CONTROLS
67 67
68/* The A15 and A25 support more sampling rates, in fact they support crazy high bit-rates such
69 * as 176.4 and 192 kHz but Rockbox does not support those */
70#if defined(SONY_NWZA10) || defined(SONY_NWA20)
71#define HW_SAMPR_CAPS (SAMPR_CAP_44 | SAMPR_CAP_48 | SAMPR_CAP_88 | SAMPR_CAP_96)
72#endif
73
68/* KeyPad configuration for plugins */ 74/* KeyPad configuration for plugins */
69#define CONFIG_KEYPAD SONY_NWZ_PAD 75#define CONFIG_KEYPAD SONY_NWZ_PAD
70#define HAS_BUTTON_HOLD 76#define HAS_BUTTON_HOLD
diff --git a/firmware/target/hosted/alsa-controls.c b/firmware/target/hosted/alsa-controls.c
index 9747fbefa9..289f2e76c9 100644
--- a/firmware/target/hosted/alsa-controls.c
+++ b/firmware/target/hosted/alsa-controls.c
@@ -72,6 +72,15 @@ bool alsa_controls_find(snd_ctl_elem_id_t *id, const char *name)
72 return false; 72 return false;
73} 73}
74 74
75bool alsa_has_control(const char *name)
76{
77 snd_ctl_elem_id_t *id;
78 /* allocate things on stack */
79 snd_ctl_elem_id_alloca(&id);
80 /* find control */
81 return alsa_controls_find(id, name);
82}
83
75/* find a control element enum index by name, return -1 if not found */ 84/* find a control element enum index by name, return -1 if not found */
76int alsa_controls_find_enum(const char *name, const char *enum_name) 85int alsa_controls_find_enum(const char *name, const char *enum_name)
77{ 86{
diff --git a/firmware/target/hosted/alsa-controls.h b/firmware/target/hosted/alsa-controls.h
index ea2475a98e..f5c8439721 100644
--- a/firmware/target/hosted/alsa-controls.h
+++ b/firmware/target/hosted/alsa-controls.h
@@ -34,6 +34,8 @@ void alsa_controls_close(void);
34/* find a control element ID by name, return false of not found, the id needs 34/* find a control element ID by name, return false of not found, the id needs
35 * to be allocated */ 35 * to be allocated */
36bool alsa_controls_find(snd_ctl_elem_id_t *id, const char *name); 36bool alsa_controls_find(snd_ctl_elem_id_t *id, const char *name);
37/* check wether a control exists */
38bool alsa_has_control(const char *name);
37/* find a control element enum index by name, return -1 if not found */ 39/* find a control element enum index by name, return -1 if not found */
38int alsa_controls_find_enum(const char *name, const char *enum_name); 40int alsa_controls_find_enum(const char *name, const char *enum_name);
39/* set a control, potentially supports several values */ 41/* set a control, potentially supports several values */
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
index c84679e9f3..f6a3ffce71 100644
--- a/firmware/target/hosted/pcm-alsa.c
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -479,6 +479,10 @@ static void pcm_dma_apply_settings_nolock(void)
479{ 479{
480 snd_pcm_drop(handle); 480 snd_pcm_drop(handle);
481 set_hwparams(handle, pcm_sampr); 481 set_hwparams(handle, pcm_sampr);
482#if defined(HAVE_NWZ_LINUX_CODEC)
483 /* Sony NWZ linux driver uses a nonstandard mecanism to set the sampling rate */
484 audiohw_set_frequency(pcm_sampr);
485#endif
482} 486}
483 487
484void pcm_dma_apply_settings(void) 488void pcm_dma_apply_settings(void)