Multicolor Framework: brightness-model vs curve definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I have been thinking about the last Multicolor Framework proposal by
Dan.

I think that the brightness-model solution to channel non-linearity and
non-uniformness is not optimal:
  1. user is only able to set color levels for colors defined in the
     models if they want linearity and uniformness. So if I have a RGB
     LED with brightness models for orange, yellow, magneta, and a few
     other colors, I can set only those colors reliably
  2. the device tree definition would be unnecessarily long if I want
     to define 100 levels for 6 colors... That's 600 lines of device
     tree code.

I therefore propose that instead of brightness-model nodes the device
tree should contain LED curve definition.

This way the interface can provide API by which the user is able to set
"arbitrary" color reliably (the interfaces provides uniformness between
channels and linearity in each channel) and the device tree does not have
to grow as fast as with the brightness-models.

I believe this would also address the problems Jacek was fearing.

The API could look something like this:
  The directory /sys/class/leds/<led>/colors should contain
      sync and sync_enable as proposed by Dan, and directory for each
      color
  The directory /sys/class/leds/<led>/colors/<color> shold contain
      enable_curve_transformation
          if this attribute == 1, the brightness and max_brightness
          attributes are transformed via the curve definition,
          otherwise they are raw values written/read from the controller
          This attribute is available only if the LED has a
          transformation curve defined.
      brightness
      max_brightness

A multi-color LED should be specified as in Dan's proposal, but without
the brightness model nodes/properties.
If a color channel node of a multi-color LED contains a led-curve
property (a phandle to a curve specifiaction), the curve transformation
should be available for this color channel.

A LED curve shall be defined as a device tree node with
led-curve-definition property.
This node can contain a string name property (is this needed? I don't
think so), and a array of points, each point a pair of integers.
The curve is defined by these points, it passes them and between each
two points it is linear (I don't believe bezier curves or something
else is needed).
A point <X Y> is interpreted as:
  X is the value written to brightness, it should be transformed to Y
  Y is the value written to HW
Example:
        curve-red {
                led-curve-definition;
                name = "red";
                points = <0 0>, <10 1>, <22 2>, <40 3>,
                         <60 6>, <90, 9>, <128 14>,
                         <192, 20>, ..., <255 255>;
        };

Example (some properties, like #address-cells are omitted):

led-controller@30 {
        compatible = "xyz";
        reg = <0x30>;

        curve_red: curve-red {
                led-curve-definition;
                name = "red";
                points = <0 0>, <10 1>, <22 2>, <40 3>,
                         <60 6>, <90, 9>, <128 14>,
                         <192, 20>, ..., <255 255>;
        };
        curve_green: curve-green {
                led-curve-definition;
                name = "green";
                points = <0 0>, <255 90>;
        };
        curve_blue: curve-blue {
                led-curve-definition;
                name = "blue";
                points = <0 0>, <255 90>;
        };

        multi-led@0 {
                reg = <0>;
                color = <LED_COLOR_ID_MULTI>;

                led@12 {
                        reg = <12>;
                        color = <LED_COLOR_ID_RED>;
                        led-curve = <&curve_red>;
                };

                led@13 {
                        reg = <13>;
                        color = <LED_COLOR_ID_GREEN>;
                        led-curve = <&curve_green>;
                };

                led@14 {
                        reg = <14>;
                        color = <LED_COLOR_ID_BLUE>;
                        led-curve = <&curve_blue>;
                };
        };
};

What do you think?

Marek



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux