Date:2012-03-06 14:15:05 (8 years 6 months ago)
Author:Paul Cercueil
Commit:ae56dee43db20497a8cb74a9df70046557705f6e
Message:MIPS: JZ4740: add the 'panel' attribute to /sys

The panel can now be changed at runtime.
Files: drivers/video/jz4740_slcd.h (1 diff)
drivers/video/jz4740_slcd_fb.c (3 diffs)
drivers/video/jz4740_slcd_panels.c (1 diff)

Change Details

drivers/video/jz4740_slcd.h
114114    const char *name;
115115};
116116
117const struct jz_slcd_panel *jz_slcd_panel_from_name(const char *name);
117118const struct jz_slcd_panel *jz_slcd_panels_probe(struct jzfb *jzfb);
118119
119120#endif /*__JZ4740_SLCD_H__*/
drivers/video/jz4740_slcd_fb.c
679679    return 0;
680680}
681681
682static ssize_t jzfb_panel_show(struct device *dev, struct device_attribute *attr,
683            char *buf)
684{
685    struct jzfb *jzfb = dev_get_drvdata(dev);
686    return sprintf(buf, "%s\n", jzfb->panel->name);
687}
688
689static ssize_t jzfb_panel_store(struct device *dev, struct device_attribute *attr,
690            const char *buf, size_t n)
691{
692    struct jzfb *jzfb = dev_get_drvdata(dev);
693    const struct jz_slcd_panel *panel = jz_slcd_panel_from_name(buf);
694
695    if (!panel) {
696        dev_err(dev, "Unknown SLCD panel: %s\n", buf);
697        return -EINVAL;
698    }
699
700    if (panel != jzfb->panel) {
701        jzfb->panel->disable(jzfb);
702        jzfb->panel->exit(jzfb);
703        jzfb->panel = panel;
704        panel->init(jzfb);
705        panel->enable(jzfb);
706    }
707    return n;
708}
709
710static DEVICE_ATTR(panel, 0644, jzfb_panel_show, jzfb_panel_store);
711
682712static struct fb_ops jzfb_ops = {
683713    .owner = THIS_MODULE,
684714    .fb_check_var = jzfb_check_var,
...... 
837867    INIT_DELAYED_WORK(&jzfb->refresh_work, jzfb_refresh_work);
838868    schedule_delayed_work(&jzfb->refresh_work, 0);
839869
840    return 0;
870    ret = device_create_file(&pdev->dev, &dev_attr_panel);
871    if (!ret)
872        return 0;
841873
874    cancel_delayed_work_sync(&jzfb->refresh_work);
842875err_free_panel:
843876    jzfb->panel->exit(jzfb);
844877err_free_devmem:
...... 
865898{
866899    struct jzfb *jzfb = platform_get_drvdata(pdev);
867900
901    device_remove_file(&pdev->dev, &dev_attr_panel);
868902    jzfb_blank(FB_BLANK_POWERDOWN, jzfb->fb);
869903
870904    /* Blanking will prevent future refreshes from behind scheduled.
drivers/video/jz4740_slcd_panels.c
511511module_param_named(panel, default_slcd_panel, charp, 0);
512512MODULE_PARM_DESC(panel, "SLCD panel used on the device");
513513
514static const struct jz_slcd_panel *jz_slcd_panel_from_name(const char *name)
514const struct jz_slcd_panel *jz_slcd_panel_from_name(const char *name)
515515{
516516    unsigned int i;
517517    for (i = 0; i < ARRAY_SIZE(jz_slcd_panels); i++) {

Archive Download the corresponding diff file



interactive