Date:2012-03-06 14:06:12 (8 years 6 months ago)
Author:Paul Cercueil
Commit:38763adfadb6b3e5f68153b97b52a9a660b3f949
Message:MIPS: JZ4740: add the 'rgb' attribute to /sys.

The color lookup table of the ili9338 panel can now be changed
at runtime.
Files: drivers/video/jz4740_slcd_panels.c (3 diffs)

Change Details

drivers/video/jz4740_slcd_panels.c
351351module_param_array_named(rgb, default_slcd_rgb, uint, NULL, 0);
352352MODULE_PARM_DESC(rgb, "comma-separated list of three values representing the percentage of red, green and blue");
353353
354static ssize_t rgb_show(struct device *dev, struct device_attribute *attr,
355            char *buf)
356{
357    struct jzfb *jzfb = dev_get_drvdata(dev);
358    return sprintf(buf, "%u,%u,%u\n", jzfb->rgb[0],
359                jzfb->rgb[1], jzfb->rgb[2]);
360}
361
362static ssize_t rgb_store(struct device *dev, struct device_attribute *attr,
363            const char *buf, size_t n)
364{
365    struct jzfb *jzfb = dev_get_drvdata(dev);
366    unsigned int rgb[3];
367
368    if (sscanf(buf, "%u,%u,%u", &rgb[0], &rgb[1], &rgb[2]) < 3)
369        return -EINVAL;
370
371    if (rgb[0] > 100 || rgb[1] > 100 || rgb[2] > 100)
372        return -EINVAL;
373
374    memcpy(jzfb->rgb, rgb, sizeof(rgb));
375    ili9338_set_color_table(jzfb);
376    return n;
377}
378
379static DEVICE_ATTR(rgb, 0644, rgb_show, rgb_store);
380
354381#define ILI9338_GPIO_CS_N JZ_GPIO_PORTB(17) /* Chip select */
355382#define ILI9338_GPIO_RESET_N JZ_GPIO_PORTB(18) /* LCD reset */
356383
...... 
467494
468495    memcpy(jzfb->rgb, default_slcd_rgb, sizeof(default_slcd_rgb));
469496    mdelay(100);
470    return 0;
497
498    ret = device_create_file(dev, &dev_attr_rgb);
499    if (!ret)
500        return 0;
471501
472502err_reset:
473503    gpio_free(ILI9338_GPIO_CS_N);
...... 
478508
479509static void ili9338_exit(struct jzfb *jzfb)
480510{
511    struct device *dev = &jzfb->pdev->dev;
512    device_remove_file(dev, &dev_attr_rgb);
513
481514    gpio_free(ILI9338_GPIO_CS_N);
482515    gpio_free(ILI9338_GPIO_RESET_N);
483516}

Archive Download the corresponding diff file



interactive