Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: led_strip: ws2812: Remove scratch selection #64525

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

thedjnK
Copy link
Collaborator

@thedjnK thedjnK commented Oct 28, 2023

The WS2812 LED strip driver does not use a scratch byte, therefore free up a byte per pixel which was unused.

@zephyrbot zephyrbot added Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. area: LED Label to identify LED subsystem labels Oct 28, 2023
nashif
nashif previously approved these changes Oct 28, 2023
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and well caught !

carlescufi
carlescufi previously approved these changes Oct 30, 2023
@fabiobaltieri
Copy link
Member

@mbolivar-ampere ping

@simonguinot simonguinot self-requested a review November 3, 2023 10:01
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @thedjnK,

After a second look I think this patch breaks the ws2812_gpio driver. See the ws2812_gpio_update_rgb fonction. Without the scratch byte and if the targeted color mapping is not RGB, then the red color (and possibly green too) is overwritten.

You can solve the issue by adding some intermediary variables. For example:


        /* Convert from RGB to on-wire format (e.g. GRB, GRBW, RGB, etc) */
        for (i = 0; i < num_pixels; i++) {
                uint8_t r = pixels[i].r;
                uint8_t g = pixels[i].g;
                uint8_t b = pixels[i].b;
                uint8_t j;

                for (j = 0; j < config->num_colors; j++) {
                        switch (config->color_mapping[j]) {
                        /* White channel is not supported by LED strip API. */
                        case LED_COLOR_ID_WHITE:
                                *ptr++ = 0;
                                break;
                        case LED_COLOR_ID_RED:
                                *ptr++ = r;
                                break;
                        case LED_COLOR_ID_GREEN:
                                *ptr++ = g;
                                break;
                        case LED_COLOR_ID_BLUE:
                                *ptr++ = b;
                                break;
                        default:
                                return -EINVAL;
                        }
                }
        }

Sorry for missing that with my initial review.

@simonguinot
Copy link
Collaborator

Sorry for missing that with my initial review.

And also for introducing this weakness with 4ada0bb

@simonguinot
Copy link
Collaborator

@thedjnK are you OK to update this PR ?

@thedjnK
Copy link
Collaborator Author

thedjnK commented Nov 18, 2023

Yes, busy with other things but will get back to this some time

The WS2812 LED strip driver does not use a scratch byte, therefore
free up a byte per pixel which was unused except in the GPIO-based
driver whereby it is used

Signed-off-by: Jamie McCrae <[email protected]>
fabiobaltieri
fabiobaltieri previously approved these changes Nov 21, 2023
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@carlescufi carlescufi merged commit 5afaa38 into zephyrproject-rtos:main Nov 24, 2023
35 checks passed
@thedjnK thedjnK deleted the saynotounneededscratch branch December 10, 2023 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LED Label to identify LED subsystem Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants