Date:2011-10-09 01:26:05 (8 years 9 months ago)
Author:Maarten ter Huurne
Commit:ed96d8b8595461bb55ca0643934fffba04f540b6
Message:media: radio: RDA5807: Implemented VIDIOC_G_FREQUENCY ioctl.

Files: drivers/media/radio/radio-rda5807.c (4 diffs)

Change Details

drivers/media/radio/radio-rda5807.c
7878#define RDA5807_MASK_SEEKRES_COMPLETE BIT(14)
7979#define RDA5807_MASK_SEEKRES_FAIL BIT(13)
8080#define RDA5807_MASK_SEEKRES_STEREO BIT(10)
81#define RDA5807_MASK_SEEKRES_READCHAN 0x3FF
8182
8283#define RDA5807_MASK_DEEMPHASIS BIT(11)
8384
...... 
210211                          ? RDA5807_MASK_DEEMPHASIS : 0);
211212}
212213
214static int rda5807_get_frequency(struct rda5807_driver *radio)
215{
216    u32 freq_khz;
217    u16 val;
218    int err;
219
220    err = rda5807_i2c_read(radio->i2c_client, RDA5807_REG_SEEK_RESULT);
221    if (err < 0)
222        return err;
223    val = err;
224
225    freq_khz = 50 * (val & RDA5807_MASK_SEEKRES_READCHAN)
226         + RDA5807_FREQ_MIN_KHZ;
227    dev_info(&radio->i2c_client->dev, "get freq of %u kHz\n", freq_khz);
228    return freq_khz;
229}
230
213231static int rda5807_set_frequency(struct rda5807_driver *radio, u32 freq_khz)
214232{
215233    u16 mask = 0;
...... 
346364    return 0;
347365}
348366
367static int rda5807_vidioc_g_frequency(struct file *file, void *fh,
368                      struct v4l2_frequency *a)
369{
370    struct rda5807_driver *radio = video_drvdata(file);
371    int freq_khz;
372
373    if (a->tuner != 0)
374        return -EINVAL;
375    /* This ioctl ignores the type field. */
376
377    freq_khz = rda5807_get_frequency(radio);
378    if (freq_khz < 0)
379        return freq_khz;
380
381    a->frequency = (__u32)freq_khz * 16;
382    return 0;
383}
384
349385static int rda5807_vidioc_s_frequency(struct file *file, void *fh,
350386                      struct v4l2_frequency *a)
351387{
...... 
363399    .vidioc_querycap = rda5807_vidioc_querycap,
364400    .vidioc_g_audio = rda5807_vidioc_g_audio,
365401    .vidioc_g_tuner = rda5807_vidioc_g_tuner,
402    .vidioc_g_frequency = rda5807_vidioc_g_frequency,
366403    .vidioc_s_frequency = rda5807_vidioc_s_frequency,
367404};
368405

Archive Download the corresponding diff file



interactive