Date: | 2013-04-27 15:05:14 (10 years 11 months ago) |
---|---|
Author: | Lars C. |
Commit: | f180eb2fa8eb97fff8e5d36dcf0eeee92ef58165 |
Message: | media/radio/radio-rda5807.c: Wait for seek complete before return All applications expects that the radio drivers make a synchronous seek when trying to find radio stations. So this feature is implemented here. The rationale: The hardware seek operation needs 35 msecs per frequency. We will wait until the hardware finds a radio station, waiting 35 msecs for each frequency (default spacing is 100 kHz). When the flag STC (Seek/Tune Complete) is set, it means that the hardware found a valid radio station, so we can return to the application. If we don't find a radio station, we will return -ETIMEDOUT to the application. Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com> Maarten ter Huurne: Reworded comments, expressed timeout count using constants rather than resulting value, return immediately when tuned instead of breaking out of the loop first. |
Files: |
drivers/media/radio/radio-rda5807.c (2 diffs) |
Change Details
drivers/media/radio/radio-rda5807.c | ||
---|---|---|
269 | 269 | { |
270 | 270 | u16 mask = 0; |
271 | 271 | u16 val = 0; |
272 | int ret, count = 0; | |
272 | 273 | |
273 | 274 | /* TODO: Seek threshold is configurable. How should the driver handle |
274 | 275 | * this configuration? |
... | ... | |
285 | 286 | mask |= RDA5807_MASK_CTRL_SEEK; |
286 | 287 | val |= RDA5807_MASK_CTRL_SEEK; |
287 | 288 | |
288 | return rda5807_update_reg(radio, RDA5807_REG_CTRL, mask, val); | |
289 | ret = rda5807_update_reg(radio, RDA5807_REG_CTRL, mask, val); | |
290 | if (ret < 0) | |
291 | return ret; | |
292 | ||
293 | while (1) { | |
294 | /* | |
295 | * The programming guide says we should wait for 35 ms for each | |
296 | * frequency tested. | |
297 | */ | |
298 | msleep(35); | |
299 | ||
300 | ret = rda5807_i2c_read(radio->i2c_client, | |
301 | RDA5807_REG_SEEK_RESULT); | |
302 | if (ret < 0) | |
303 | return ret; | |
304 | ||
305 | /* Seek done? */ | |
306 | if (ret & RDA5807_MASK_SEEKRES_COMPLETE) | |
307 | return 0; | |
308 | ||
309 | /* | |
310 | * Channel spacing is 100 kHz. | |
311 | * TODO: Should we support configurable spacing? | |
312 | */ | |
313 | count++; | |
314 | if (count > (RDA5807_FREQ_MAX_KHZ - RDA5807_FREQ_MIN_KHZ) / 100) | |
315 | return -ETIMEDOUT; | |
316 | } | |
289 | 317 | } |
290 | 318 | |
291 | 319 | static inline struct rda5807_driver *ctrl_to_radio(struct v4l2_ctrl *ctrl) |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9