diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2010-08-23 20:49:33 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2010-08-23 20:49:33 +0000 |
commit | aea21cd18be1069e23d4703fd1daca616e2c2940 (patch) | |
tree | dbb60f293ac34e3d4ba6bfcd1880f4c22362c383 | |
parent | e70bc182cf86799e1e5fdc5ca7a29b74a860d864 (diff) | |
download | rockbox-aea21cd18be1069e23d4703fd1daca616e2c2940.tar.gz rockbox-aea21cd18be1069e23d4703fd1daca616e2c2940.zip |
ipod fm remote: some static/const fixes from FS #11266 by me
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27867 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/tuner/ipod_remote_tuner.c | 83 | ||||
-rw-r--r-- | firmware/export/ipod_remote_tuner.h | 17 |
2 files changed, 42 insertions, 58 deletions
diff --git a/firmware/drivers/tuner/ipod_remote_tuner.c b/firmware/drivers/tuner/ipod_remote_tuner.c index 52d93b8b34..a20735402e 100644 --- a/firmware/drivers/tuner/ipod_remote_tuner.c +++ b/firmware/drivers/tuner/ipod_remote_tuner.c | |||
@@ -35,22 +35,28 @@ static bool powered = false; | |||
35 | 35 | ||
36 | static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF; | 36 | static unsigned char tuner_param = 0x00, old_tuner_param = 0xFF; |
37 | /* temp var for tests to avoid looping execution in submenus settings*/ | 37 | /* temp var for tests to avoid looping execution in submenus settings*/ |
38 | int mono_mode = -1, old_region = -1; | 38 | static int mono_mode = -1, old_region = -1; |
39 | 39 | ||
40 | int radio_present = 0; | 40 | int radio_present = 0; |
41 | int tuner_frequency = 0; | ||
42 | int tuner_signal_power = 0; | ||
43 | int radio_tuned = 0; | ||
44 | int rds_event = 0; | ||
45 | 41 | ||
46 | char rds_radioname[9]; | 42 | static int tuner_frequency = 0; |
47 | char rds_radioinfo[65]; | 43 | static int tuner_signal_power = 0; |
44 | static bool radio_tuned = false; | ||
45 | static bool rds_event = false; | ||
48 | 46 | ||
49 | union FRQ { | 47 | static char rds_radioname[9]; |
48 | static char rds_radioinfo[65]; | ||
49 | |||
50 | static union FRQ { | ||
50 | unsigned long int frequency_radio; | 51 | unsigned long int frequency_radio; |
51 | char data_frequency[4]; | 52 | char data_frequency[4]; |
52 | }Frequency; | 53 | }Frequency; |
53 | 54 | ||
55 | static void rmt_tuner_signal_power(unsigned char value) | ||
56 | { | ||
57 | tuner_signal_power = (int)(value); | ||
58 | } | ||
59 | |||
54 | void rmt_tuner_freq(void) | 60 | void rmt_tuner_freq(void) |
55 | { | 61 | { |
56 | char tempdata[4]; | 62 | char tempdata[4]; |
@@ -61,15 +67,15 @@ void rmt_tuner_freq(void) | |||
61 | 67 | ||
62 | memcpy(Frequency.data_frequency,tempdata,4); | 68 | memcpy(Frequency.data_frequency,tempdata,4); |
63 | tuner_frequency = (Frequency.frequency_radio*1000); | 69 | tuner_frequency = (Frequency.frequency_radio*1000); |
64 | radio_tuned = 1; | 70 | radio_tuned = true; |
65 | rmt_tuner_signal_power(serbuf[7]); | 71 | rmt_tuner_signal_power(serbuf[7]); |
66 | } | 72 | } |
67 | 73 | ||
68 | void rmt_tuner_set_freq(int curr_freq) | 74 | static void rmt_tuner_set_freq(int curr_freq) |
69 | { | 75 | { |
70 | if (curr_freq != tuner_frequency) | 76 | if (curr_freq != tuner_frequency) |
71 | { | 77 | { |
72 | radio_tuned = 0; | 78 | radio_tuned = false; |
73 | tuner_signal_power = 0; | 79 | tuner_signal_power = 0; |
74 | /* clear rds name and info */ | 80 | /* clear rds name and info */ |
75 | memset(rds_radioname,' ',sizeof(rds_radioname)); | 81 | memset(rds_radioname,' ',sizeof(rds_radioname)); |
@@ -94,12 +100,7 @@ void rmt_tuner_set_freq(int curr_freq) | |||
94 | } | 100 | } |
95 | } | 101 | } |
96 | 102 | ||
97 | void rmt_tuner_signal_power(unsigned char value) | 103 | static void rmt_tuner_sleep(int state) |
98 | { | ||
99 | tuner_signal_power = (int)(value); | ||
100 | } | ||
101 | |||
102 | void rmt_tuner_sleep(int state) | ||
103 | { | 104 | { |
104 | if (state == 0) | 105 | if (state == 0) |
105 | { | 106 | { |
@@ -108,41 +109,41 @@ void rmt_tuner_sleep(int state) | |||
108 | mono_mode = -1; | 109 | mono_mode = -1; |
109 | old_region = -1; | 110 | old_region = -1; |
110 | tuner_frequency = 0; | 111 | tuner_frequency = 0; |
111 | radio_tuned = 0; | 112 | radio_tuned = false; |
112 | 113 | ||
113 | /* tuner HW on */ | 114 | /* tuner HW on */ |
114 | unsigned char data[] = {0x07, 0x05, 0x01}; | 115 | const unsigned char data[] = {0x07, 0x05, 0x01}; |
115 | iap_send_pkt(data, sizeof(data)); | 116 | iap_send_pkt(data, sizeof(data)); |
116 | /* boost gain */ | 117 | /* boost gain */ |
117 | unsigned char data1[] = {0x07, 0x24, 0x06 }; | 118 | const unsigned char data1[] = {0x07, 0x24, 0x06 }; |
118 | iap_send_pkt(data1, sizeof(data1)); | 119 | iap_send_pkt(data1, sizeof(data1)); |
119 | /* set volume */ | 120 | /* set volume */ |
120 | unsigned char data2[] = {0x03, 0x09, 0x04, 0x00, 0x00 }; | 121 | unsigned char data2[] = {0x03, 0x09, 0x04, 0x00, 0x00 }; |
121 | data2[4] = (char)((global_settings.volume+58) * 4); | 122 | data2[4] = (char)((global_settings.volume+58) * 4); |
122 | iap_send_pkt(data2, sizeof(data2)); | 123 | iap_send_pkt(data2, sizeof(data2)); |
123 | /* set rds on */ | 124 | /* set rds on */ |
124 | unsigned char data3[] = {0x07, 0x20, 0x40, 0x00, 0x00, 0x10 }; | 125 | const unsigned char data3[] = {0x07, 0x20, 0x40, 0x00, 0x00, 0x10 }; |
125 | iap_send_pkt(data3, sizeof(data3)); | 126 | iap_send_pkt(data3, sizeof(data3)); |
126 | } | 127 | } |
127 | else | 128 | else |
128 | { | 129 | { |
129 | /* unbooste gain */ | 130 | /* unbooste gain */ |
130 | unsigned char data[] = {0x07, 0x24, 0x00}; | 131 | const unsigned char data[] = {0x07, 0x24, 0x00}; |
131 | iap_send_pkt(data, sizeof(data)); | 132 | iap_send_pkt(data, sizeof(data)); |
132 | /* set rds off */ | 133 | /* set rds off */ |
133 | unsigned char data1[] = {0x07, 0x20, 0x00, 0x00, 0x00, 0x00 }; | 134 | const unsigned char data1[] = {0x07, 0x20, 0x00, 0x00, 0x00, 0x00 }; |
134 | iap_send_pkt(data1, sizeof(data1)); | 135 | iap_send_pkt(data1, sizeof(data1)); |
135 | /* stop tuner HW */ | 136 | /* stop tuner HW */ |
136 | unsigned char data2[] = {0x07, 0x05, 0x00}; | 137 | const unsigned char data2[] = {0x07, 0x05, 0x00}; |
137 | iap_send_pkt(data2, sizeof(data2)); | 138 | iap_send_pkt(data2, sizeof(data2)); |
138 | } | 139 | } |
139 | } | 140 | } |
140 | 141 | ||
141 | void rmt_tuner_scan(int param) | 142 | static void rmt_tuner_scan(int param) |
142 | { | 143 | { |
143 | unsigned char data[] = {0x07, 0x11, 0x08}; /* RSSI level */ | 144 | const unsigned char data[] = {0x07, 0x11, 0x08}; /* RSSI level */ |
144 | unsigned char updown = 0x00; | 145 | unsigned char updown = 0x00; |
145 | radio_tuned = 0; | 146 | radio_tuned = false; |
146 | iap_send_pkt(data, sizeof(data)); | 147 | iap_send_pkt(data, sizeof(data)); |
147 | 148 | ||
148 | if (param == 1) | 149 | if (param == 1) |
@@ -161,7 +162,8 @@ void rmt_tuner_scan(int param) | |||
161 | iap_send_pkt(data1, sizeof(data1)); | 162 | iap_send_pkt(data1, sizeof(data1)); |
162 | } | 163 | } |
163 | 164 | ||
164 | void rmt_tuner_mute(int value) | 165 | #if 0 /* function is not used */ |
166 | static void rmt_tuner_mute(int value) | ||
165 | { | 167 | { |
166 | /* mute flag off (play) */ | 168 | /* mute flag off (play) */ |
167 | unsigned char data[] = {0x03, 0x09, 0x03, 0x01}; | 169 | unsigned char data[] = {0x03, 0x09, 0x03, 0x01}; |
@@ -172,8 +174,9 @@ void rmt_tuner_mute(int value) | |||
172 | } | 174 | } |
173 | iap_send_pkt(data, sizeof(data)); | 175 | iap_send_pkt(data, sizeof(data)); |
174 | } | 176 | } |
177 | #endif | ||
175 | 178 | ||
176 | void rmt_tuner_region(int region) | 179 | static void rmt_tuner_region(int region) |
177 | { | 180 | { |
178 | if (region != old_region) | 181 | if (region != old_region) |
179 | { | 182 | { |
@@ -194,7 +197,7 @@ void rmt_tuner_region(int region) | |||
194 | } | 197 | } |
195 | 198 | ||
196 | /* set stereo/mono, deemphasis, delta freq... */ | 199 | /* set stereo/mono, deemphasis, delta freq... */ |
197 | void rmt_tuner_set_param(unsigned char tuner_param) | 200 | static void rmt_tuner_set_param(unsigned char tuner_param) |
198 | { | 201 | { |
199 | if(tuner_param != old_tuner_param) | 202 | if(tuner_param != old_tuner_param) |
200 | { | 203 | { |
@@ -279,9 +282,7 @@ static bool reply_timeout(void) | |||
279 | } | 282 | } |
280 | while((ipod_rmt_tuner_get(RADIO_TUNED) == 0) && (timeout < TIMEOUT_VALUE)); | 283 | while((ipod_rmt_tuner_get(RADIO_TUNED) == 0) && (timeout < TIMEOUT_VALUE)); |
281 | 284 | ||
282 | if (timeout >= TIMEOUT_VALUE) | 285 | return (timeout >= TIMEOUT_VALUE); |
283 | return true; | ||
284 | else return false; | ||
285 | } | 286 | } |
286 | 287 | ||
287 | void rmt_tuner_rds_data(void) | 288 | void rmt_tuner_rds_data(void) |
@@ -294,7 +295,7 @@ void rmt_tuner_rds_data(void) | |||
294 | { | 295 | { |
295 | strlcpy(rds_radioinfo,serbuf+5,(serbuf[0]-4)); | 296 | strlcpy(rds_radioinfo,serbuf+5,(serbuf[0]-4)); |
296 | } | 297 | } |
297 | rds_event = 1; | 298 | rds_event = true; |
298 | } | 299 | } |
299 | 300 | ||
300 | /* tuner abstraction layer: set something to the tuner */ | 301 | /* tuner abstraction layer: set something to the tuner */ |
@@ -327,13 +328,13 @@ int ipod_rmt_tuner_set(int setting, int value) | |||
327 | &fm_region_data[global_settings.fm_region]; | 328 | &fm_region_data[global_settings.fm_region]; |
328 | 329 | ||
329 | /* case: scan for presets, back to beginning of the band */ | 330 | /* case: scan for presets, back to beginning of the band */ |
330 | if ((radio_tuned == 1) && (value == fmr->freq_min)) | 331 | if (radio_tuned && (value == fmr->freq_min)) |
331 | { | 332 | { |
332 | tuner_set(RADIO_FREQUENCY,value); | 333 | tuner_set(RADIO_FREQUENCY,value); |
333 | } | 334 | } |
334 | 335 | ||
335 | /* scan through frequencies */ | 336 | /* scan through frequencies */ |
336 | if (radio_tuned == 1) | 337 | if (radio_tuned) |
337 | { | 338 | { |
338 | if ((tuner_frequency <= fmr->freq_min) | 339 | if ((tuner_frequency <= fmr->freq_min) |
339 | && (tuner_frequency >= fmr->freq_max)) | 340 | && (tuner_frequency >= fmr->freq_max)) |
@@ -355,17 +356,17 @@ int ipod_rmt_tuner_set(int setting, int value) | |||
355 | if (reply_timeout() == true) | 356 | if (reply_timeout() == true) |
356 | return 0; | 357 | return 0; |
357 | } | 358 | } |
358 | radio_tuned = 0; | 359 | radio_tuned = false; |
359 | } | 360 | } |
360 | 361 | ||
361 | if (tuner_frequency == value) | 362 | if (tuner_frequency == value) |
362 | { | 363 | { |
363 | radio_tuned = 1; | 364 | radio_tuned = true; |
364 | return 1; | 365 | return 1; |
365 | } | 366 | } |
366 | else | 367 | else |
367 | { | 368 | { |
368 | radio_tuned = 0; | 369 | radio_tuned = false; |
369 | return 0; | 370 | return 0; |
370 | } | 371 | } |
371 | } | 372 | } |
@@ -426,7 +427,7 @@ int ipod_rmt_tuner_get(int setting) | |||
426 | /* radio tuned: yes no */ | 427 | /* radio tuned: yes no */ |
427 | case RADIO_TUNED: | 428 | case RADIO_TUNED: |
428 | val = 0; | 429 | val = 0; |
429 | if (radio_tuned == 1) | 430 | if (radio_tuned) |
430 | val = 1; | 431 | val = 1; |
431 | break; | 432 | break; |
432 | 433 | ||
@@ -441,7 +442,7 @@ int ipod_rmt_tuner_get(int setting) | |||
441 | if (rds_event) | 442 | if (rds_event) |
442 | { | 443 | { |
443 | val = 1; | 444 | val = 1; |
444 | rds_event = 0; | 445 | rds_event = false; |
445 | } | 446 | } |
446 | break; | 447 | break; |
447 | } | 448 | } |
diff --git a/firmware/export/ipod_remote_tuner.h b/firmware/export/ipod_remote_tuner.h index 2c866ad3d2..c22978b0e4 100644 --- a/firmware/export/ipod_remote_tuner.h +++ b/firmware/export/ipod_remote_tuner.h | |||
@@ -27,25 +27,8 @@ | |||
27 | #define TIMEOUT_VALUE 20 | 27 | #define TIMEOUT_VALUE 20 |
28 | 28 | ||
29 | extern int radio_present; | 29 | extern int radio_present; |
30 | extern int tuner_frequency; | ||
31 | extern int tuner_signal_power; | ||
32 | extern int radio_tuned; | ||
33 | 30 | ||
34 | /* update tuner state: plugged or unplugged when in radio mode */ | ||
35 | extern void rmt_tuner_region(int region); | ||
36 | extern void rmt_tuner_set_freq(int curr_freq); | ||
37 | extern void rmt_tuner_freq(void); | 31 | extern void rmt_tuner_freq(void); |
38 | extern void rmt_tuner_scan(int direction); | ||
39 | |||
40 | /* tuner mode state: ON or OFF */ | ||
41 | extern void rmt_tuner_sleep(int state); | ||
42 | |||
43 | /* parameters are stereo/mono, deemphasis, delta freq... */ | ||
44 | extern void rmt_tuner_set_param(unsigned char tuner_param); | ||
45 | |||
46 | extern void rmt_tuner_mute(int value); | ||
47 | extern void rmt_tuner_signal_power(unsigned char value); | ||
48 | |||
49 | extern void rmt_tuner_rds_data(void); | 32 | extern void rmt_tuner_rds_data(void); |
50 | 33 | ||
51 | int ipod_rmt_tuner_set(int setting, int value); | 34 | int ipod_rmt_tuner_set(int setting, int value); |