Date:2012-05-12 20:29:20 (8 years 5 months ago)
Author:Paul Cercueil
Commit:6068b05c7139d15900294dced349a7229f967543
Message:MIPS: JZ4740: SLCD: Toggle TV-out through /sys instead of ioctl.

The state of the TV-out can now be known from userspace by reading
the corresponding /sys entry.
Files: drivers/video/jz4740_slcd.h (1 diff)
drivers/video/jz4740_slcd_fb.c (7 diffs)

Change Details

drivers/video/jz4740_slcd.h
103103    struct clk *ldclk;
104104    struct clk *lpclk;
105105
106    unsigned int tv_out;
107
106108    unsigned is_enabled:1;
107109    struct mutex lock; /* Protecting against running enable/disable in paralell */
108110
drivers/video/jz4740_slcd_fb.c
3434#include "jz4740_lcd.h"
3535#include "jz4740_slcd.h"
3636
37static const char *jzfb_tv_out_norm[] = {
38    "off", "ntsc", "pal", "pal-60", "pal-m",
39};
40
3741static struct fb_fix_screeninfo jzfb_fix __devinitdata = {
3842    .id = "JZ4740 SLCD FB",
3943    .type = FB_TYPE_PACKED_PIXELS,
...... 
605609                jzfb->framedesc, jzfb->framedesc_phys);
606610}
607611
608#include "jz4740_lcd.h"
609
610#define FBIOA320TVOUT 0x46F0
611612#define FB_A320TV_OFF 0
612613#define FB_A320TV_NTSC 1
613614#define FB_A320TV_PAL50 2
...... 
682683
683684    /* reaffirm the current blanking state, to trigger a backlight update */
684685    fb_notifier_call_chain(FB_EVENT_BLANK, &event);
686    jzfb->tv_out = mode;
685687    return 0;
686688}
687689
688static int jzfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
690static ssize_t jzfb_tv_out_show(struct device *dev, struct device_attribute *attr,
691            char *buf)
689692{
690    struct jzfb *jzfb = info->par;
691    switch (cmd) {
692        case FBIOA320TVOUT:
693            /* No TV-out mode while sleeping. */
694            if (!jzfb->is_enabled)
695                return -EBUSY;
693    struct jzfb *jzfb = dev_get_drvdata(dev);
696694
697            return jzfb_tv_out(jzfb, arg);
698        default:
699            return -EINVAL;
695    if (jzfb->tv_out > FB_A320TV_LAST) {
696        dev_err(dev, "Unknown norm for TV-out\n");
697        return -1;
700698    }
701    return 0;
699
700    return sprintf(buf, "%s\n", jzfb_tv_out_norm[jzfb->tv_out]);
702701}
703702
703static ssize_t jzfb_tv_out_store(struct device *dev, struct device_attribute *attr,
704            const char *buf, size_t n)
705{
706    size_t i;
707    struct jzfb *jzfb = dev_get_drvdata(dev);
708
709    for (i = 0; i <= FB_A320TV_LAST; i++) {
710        if (!strncmp(jzfb_tv_out_norm[i], buf, n-1)) {
711            jzfb_tv_out(jzfb, i);
712            return n;
713        }
714    }
715    return -EINVAL;
716}
717
718static DEVICE_ATTR(tv_out, 0644, jzfb_tv_out_show, jzfb_tv_out_store);
719
704720static ssize_t jzfb_panel_show(struct device *dev, struct device_attribute *attr,
705721            char *buf)
706722{
...... 
741757    .fb_fillrect = sys_fillrect,
742758    .fb_copyarea = sys_copyarea,
743759    .fb_imageblit = sys_imageblit,
744    .fb_ioctl = jzfb_ioctl,
745760    .fb_mmap = jzfb_mmap,
746761};
747762
...... 
788803    jzfb->pdata = pdata;
789804    jzfb->mem = mem;
790805
806    jzfb->tv_out = FB_A320TV_OFF;
807
791808    jzfb->dma = jz4740_dma_request(&pdev->dev, dev_name(&pdev->dev), 0);
792809    if (!jzfb->dma) {
793810        dev_err(&pdev->dev, "Failed to get DMA channel\n");
...... 
890907    schedule_delayed_work(&jzfb->refresh_work, 0);
891908
892909    ret = device_create_file(&pdev->dev, &dev_attr_panel);
910    if (ret)
911        goto err_cancel_work;
912
913    ret = device_create_file(&pdev->dev, &dev_attr_tv_out);
893914    if (!ret)
894915        return 0;
895916
917    device_remove_file(&pdev->dev, &dev_attr_panel);
918err_cancel_work:
896919    cancel_delayed_work_sync(&jzfb->refresh_work);
897920err_free_panel:
898921    jzfb->panel->exit(jzfb);
...... 
920943{
921944    struct jzfb *jzfb = platform_get_drvdata(pdev);
922945
946    device_remove_file(&pdev->dev, &dev_attr_tv_out);
923947    device_remove_file(&pdev->dev, &dev_attr_panel);
924948    jzfb_blank(FB_BLANK_POWERDOWN, jzfb->fb);
925949

Archive Download the corresponding diff file



interactive