Date:2011-10-03 00:13:25 (8 years 11 months ago)
Author:Maarten ter Huurne
Commit:144e9c2530f863e32a3538b06c63484401bbe314
Message:media: radio: RDA5807: Mute at startup; power down when muted.

This way the radio does not draw power when it is not in use.
Files: drivers/media/radio/radio-rda5807.c (5 diffs)

Change Details

drivers/media/radio/radio-rda5807.c
166166
167167static int rda5807_set_enable(struct rda5807_driver *radio, int enabled)
168168{
169    // TODO: What should control power up/down?
170    // Mute would be a candidate.
171169    u16 val = enabled ? RDA5807_MASK_CTRL_ENABLE : 0;
170    dev_info(&radio->i2c_client->dev, "set enabled to %d\n", enabled);
172171    return rda5807_update_reg(radio, RDA5807_REG_CTRL,
173172                  RDA5807_MASK_CTRL_ENABLE, val);
174173}
...... 
176175static int rda5807_set_mute(struct rda5807_driver *radio, int muted)
177176{
178177    u16 val = muted ? 0 : RDA5807_MASK_CTRL_DMUTE /* disable mute */;
178    dev_info(&radio->i2c_client->dev, "set mute to %d\n", muted);
179179    return rda5807_update_reg(radio, RDA5807_REG_CTRL,
180180                  RDA5807_MASK_CTRL_DMUTE, val);
181181}
...... 
237237    struct rda5807_driver *radio = ctrl_to_radio(ctrl);
238238
239239    switch (ctrl->id) {
240    case V4L2_CID_AUDIO_MUTE:
241        return rda5807_set_mute(radio, ctrl->val);
240    case V4L2_CID_AUDIO_MUTE: {
241        /* Disable the radio while muted, to save power.
242         * TODO: We can't seek while the radio is disabled;
243         * is that a problem?
244         */
245        int err1 = rda5807_set_enable(radio, !ctrl->val);
246        int err2 = rda5807_set_mute(radio, ctrl->val);
247        return err1 ? err1 : err2;
248    }
242249    case V4L2_CID_AUDIO_VOLUME:
243250        return rda5807_set_volume(radio, ctrl->val);
244251    case V4L2_CID_TUNE_PREEMPHASIS:
...... 
369376    /* Initialize controls. */
370377    v4l2_ctrl_handler_init(&radio->ctrl_handler, 3);
371378    v4l2_ctrl_new_std(&radio->ctrl_handler, &rda5807_ctrl_ops,
372              V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
379              V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1);
373380    v4l2_ctrl_new_std(&radio->ctrl_handler, &rda5807_ctrl_ops,
374381              V4L2_CID_AUDIO_VOLUME, 0, 15, 1, 8);
375382    v4l2_ctrl_new_std_menu(&radio->ctrl_handler, &rda5807_ctrl_ops,
...... 
409416                       " (%d)\n", err);
410417        goto err_video_unreg;
411418    }
412    // TODO: Disable on startup and enable on demand.
413    rda5807_set_enable(radio, 1);
414419
415420    return 0;
416421

Archive Download the corresponding diff file



interactive