Led flicking with Colibri imx6ull

hi, on my Colibri imx6ull, pin 64 is connected to a led, and configured as GPIO. I turned on/off the led using the following code:

bool setGPIOPinState(unsigned int pinNum, DioPinState state)
{
    struct gpiod_chip* gpioBank;
    struct gpiod_line* gpioLine;
    int ret, isSuccess = true;
    gpioBank = gpiod_chip_open_by_number(DALI_IO_pins[pinNum].bank);
    if (gpioBank)
        gpioLine = gpiod_chip_get_line(gpioBank, DALI_IO_pins[pinNum].line);
    if (gpioBank && gpioLine)
    {
        ret = gpiod_line_request_output(gpioLine, "gpio-DALI", GPIOD_LINE_ACTIVE_STATE_HIGH);
        if (ret != -1)
            gpiod_line_set_value(gpioLine, state);
        else
            isSuccess = false;
    }
    else
    {
        isSuccess = false;
    }
    if (gpioLine)
        gpiod_line_release(gpioLine);
    if (gpioBank)
        gpiod_chip_close(gpioBank);

    return isSuccess;
}

In our code, setGPIOPinState() called around 1000 times/second, and it is always set to off. I found the led is flicking, at very dim level (around 1% of full brightness).
However, if I call the setGPIOPinState() only if the status changes, the led will be completely off as expected. I do not understand why calling setGPIOPinState() frequently with same value (off) would cause it to be flicking, in stead of being off completely.
I can work around this issue by checking the state first, and set only if the new state is different. However I want to know if this is common issue of something wrong with our system. thank you

The 3d parameter of gpiod_line_request_output() is Initial line value… And value of GPIOD_LINE_ACTIVE_STATE_HIGH is 1. So when you invoke setGPIOPinState(pin, 0) its initially set selected gpio line to HIGH and then immediately set it to LOW . That’s why you see a flickering.

thanks for the reply. So how should I fix it? do I use this following?

ret = gpiod_line_request_output(gpioLine, “gpio-DALI”, GPIOD_LINE_ACTIVE_STATE_LOW);

I’d start from
gpiod_line_request_output(gpioLine, "gpio-DALI", state);