Date:2011-10-04 12:04:43 (8 years 9 months ago)
Author:Maarten ter Huurne
Commit:85dd1596e0f79827843c569b12617228f66600c1
Message:media: radio: RDA5807: Implemented suspend and resume.

On suspend, disable the chip to save power.
On resume, enable the chip if the radio device is not muted.
Files: drivers/media/radio/radio-rda5807.c (3 diffs)

Change Details

drivers/media/radio/radio-rda5807.c
3636#include <linux/module.h>
3737#include <linux/i2c.h>
3838#include <linux/kernel.h>
39#include <linux/pm.h>
3940#include <linux/slab.h>
4041#include <linux/types.h>
4142#include <linux/videodev2.h>
...... 
440441    return 0;
441442}
442443
444#ifdef CONFIG_PM
445
446static int rda5807_suspend(struct device *dev)
447{
448    struct i2c_client *client = to_i2c_client(dev);
449    struct rda5807_driver *radio = i2c_get_clientdata(client);
450
451    return rda5807_set_enable(radio, 0);
452}
453
454static int rda5807_resume(struct device *dev)
455{
456    struct i2c_client *client = to_i2c_client(dev);
457    struct rda5807_driver *radio = i2c_get_clientdata(client);
458    struct v4l2_ctrl *mute_ctrl = v4l2_ctrl_find(&radio->ctrl_handler,
459                             V4L2_CID_AUDIO_MUTE);
460    s32 mute_val = v4l2_ctrl_g_ctrl(mute_ctrl);
461    int enabled = !mute_val;
462
463    if (enabled)
464        return rda5807_set_enable(radio, enabled);
465    else
466        return 0;
467}
468
469static SIMPLE_DEV_PM_OPS(rda5807_pm_ops, rda5807_suspend, rda5807_resume);
470#define RDA5807_PM_OPS (&rda5807_pm_ops)
471
472#else
473
474#define RDA5807_PM_OPS NULL
475
476#endif
477
443478static const struct i2c_device_id rda5807_id[] = {
444479    { "radio-rda5807", 0 },
445480    { }
...... 
451486    .remove = __devexit_p(rda5807_i2c_remove),
452487    .id_table = rda5807_id,
453488    .driver = {
454        .name = "radio-rda5807",
455        .owner = THIS_MODULE,
489        .name = "radio-rda5807",
490        .owner = THIS_MODULE,
491        .pm = RDA5807_PM_OPS,
456492    },
457493};
458494

Archive Download the corresponding diff file



interactive