Date:2012-10-04 06:37:59 (7 years 2 months ago)
Author:Marcos Paulo de Souza
Commit:7b4d4278ce6008715cb70626aac3040f18831811
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
269269{
270270    u16 mask = 0;
271271    u16 val = 0;
272    int ret, count = 0;
272273
273274    /* TODO: Seek threshold is configurable. How should the driver handle
274275     * this configuration?
...... 
285286    mask |= RDA5807_MASK_CTRL_SEEK;
286287    val |= RDA5807_MASK_CTRL_SEEK;
287288
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    }
289317}
290318
291319static inline struct rda5807_driver *ctrl_to_radio(struct v4l2_ctrl *ctrl)

Archive Download the corresponding diff file



interactive