Dan,[...]
+ for (i = 0; i < mcled_cdev->num_leds; i++) {This is exactly the issue I had previously brought up. The user would need to
+ÂÂÂÂÂÂÂ ret = sscanf(buf + offset, "%i%n", &value[i], &nrchars);
+ÂÂÂÂÂÂÂ if (ret != 1)
+ÂÂÂÂÂÂÂÂÂÂÂ break;
+
+ÂÂÂÂÂÂÂ offset += nrchars;
+ÂÂÂ }
+
+ÂÂÂ if (i != mcled_cdev->num_leds) {
From what I see it will lead to wrong mapping of given color to theShouldn't we return error if i != mcled_cdev->num_leds - 1 ?Ok so during my testing if I had the monochrome array as <R G B>
How can we know which color the value will be for if there is less
values passed than the total number of colors in the cluster?
When I wrote only <R G> and no blue I was getting random values in the
array for the
remaining indexes and the blue LED would randomly turn on/off at
different levels.
So if the user passes in less then expected only ids with data will be
written and the other colors will be turned off by the for loop below.
value array element in the following case:
echo "<green> <blue>" > color_mix
Then green intensity will be assigned to value[0] (expects red) and blue
to value[1] (expects green). Unless I don't get something.
Your ABI documentation doesn't mention any way to redefine the color_id
returned by <color>/color_id file. And that is good.
I might be able to eliminate this loop by initializing the array to 0.See above but this should be+ÂÂÂÂÂÂÂ for (; i < LED_COLOR_ID_MAX; i++)What use case is it for?
+ÂÂÂÂÂÂÂÂÂÂÂ value[i] = 0;
for (; i < mcled_cdev->num_leds; i++)
Those array values would not be directly written to the device,I guess what is gained by just passing the array down to the device+ÂÂÂ }Here we could use just brightness_set op as a single call. We should
+
+ÂÂÂ list_for_each_entry(priv, &data->color_list, list) {
+ÂÂÂÂÂÂÂ if (data->cluster_brightness) {
+ÂÂÂÂÂÂÂÂÂÂÂ adj_brightness =
calculate_brightness(data->cluster_brightness,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ value[priv->color_index],
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ priv->max_intensity);
+ÂÂÂÂÂÂÂÂÂÂÂ ret = ops->set_color_brightness(priv->mcled_cdev,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ priv->color_id,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ adj_brightness);
+ÂÂÂÂÂÂÂÂÂÂÂ if (ret < 0)
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ goto done;
+ÂÂÂÂÂÂÂ }
+
+ÂÂÂÂÂÂÂ priv->intensity = value[priv->color_index];
+ÂÂÂ }
always write all colors as a result of write to color_mix anyway.
driver and having it
parse the array and do the peripheral call?
but used for calculating the actual iout intensities. Driver
will just have to call calculate_brightness() (sticking to the naming
from this patch) and write the results calculated basing on brightness
and max_brightness.
[...]
The whole need for new_intensity and cluster_brightness, and thenNot sure what complication you are referring to.+This is unnecessary complication. Just write the calculated iout
+ÂÂÂ priv->new_intensity = value;
+
+ÂÂÂ if (data->cluster_brightness) {
+ÂÂÂÂÂÂÂ adj_value = calculate_brightness(data->cluster_brightness,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ priv->new_intensity,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ priv->max_intensity);
+ÂÂÂÂÂÂÂ ret = ops->set_color_brightness(priv->mcled_cdev,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ priv->color_id, adj_value);
+ÂÂÂÂÂÂÂ if (ret < 0) {
+ÂÂÂÂÂÂÂÂÂÂÂ priv->new_intensity = priv->intensity;
intensity.
bringing back old intensity value on set_color_brightness() failure.
OK. This this would remove the ops from the driver as it is no longer needed.
But it probably should be. It would simplify the design.We need to highlight it in the documentation that exact requested colorBut that is not a true statement. Thats not really how it was designed.
intensity values are written to the hardware only when
brightness == max_brightness.
So my idea is like I previously described the way I had first understood
this design:
The colors set under colors directory don't reflect the iout
intensities, but are only used for calculating them, basing on the
brightness and max_intensity values.
Effectively, after changing the colors/<color>/intensity the global
(legacy monochrome) brightness value will be still valid, since iout
color will be recalculated basing on it and the new color intensity.