A control circuit for a power converter; wherein the power converter is configured to convert an input power derived from a mains power supply into a drive power for a light source; wherein the input power is an AC power comprising an AC voltage and an AC current; wherein the control circuit comprises - a dimmer mode detection unit configured to determine a first dimmer mode from a plurality of pre-determined dimmer modes, based on one or more sensor signals sensed at corresponding one or more nodes of the power converter; wherein the one or more sensor signals comprise an input signal indicative of a waveform of the AC voltage; and wherein the dimmer mode detection unit is configured to determine the first dimmer mode based on the input signal; wherein the plurality of pre-determined dimmer modes comprise one or more of: a mode which indicates that the input power has been derived from the mains power supply using a leading edge phase-cut dimmer; a mode which indicates that the input power has been derived from the mains power supply using a trailing edge phase-cut dimmer; and/or a mode which indicates that the input power has been derived from the mains power supply using an intelligent phase-cut dimmer, wherein the intelligent phase-cut dimmer is a dimmer which is adapted to detect the type of load and to operate depending on the detected load as leading or trailing edge phase-cut dimmer; the control circuit being characterised in that it further comprises: - a storage unit configured to store a plurality of different dimmer mode tables for the corresponding plurality of pre-determined dimmer modes; wherein a first dimmer mode table from the plurality of dimmer mode tables, which corresponds to the first dimmer mode, comprises a plurality of state information records which define a state machine for operating the power converter according to a plurality of different operation modes; wherein the plurality of different operation modes comprise an energy transfer mode, during which the power converter is operated to provide power to an energy storage unit, and a linear operation mode, during which the power converter is operated as a load; - a state processor configured to select different operation modes from the plurality of different operation modes during a cycle of the waveform of the input signal; and - a first control unit configured to generate a first control signal for operating the power converter in accordance to the selected operation mode. - a dimmer mode detection unit configured to determine a first dimmer mode from a plurality of pre-determined dimmer modes, based on one or more sensor signals sensed at corresponding one or more nodes of the power converter; wherein the one or more sensor signals comprise an input signal indicative of a waveform of the AC voltage; and wherein the dimmer mode detection unit is configured to determine the first dimmer mode based on the input signal; wherein the plurality of pre-determined dimmer modes comprise one or more of: a mode which indicates that the input power has been derived from the mains power supply using a leading edge phase-cut dimmer; a mode which indicates that the input power has been derived from the mains power supply using a trailing edge phase-cut dimmer; and/or a mode which indicates that the input power has been derived from the mains power supply using an intelligent phase-cut dimmer, wherein the intelligent phase-cut dimmer is a dimmer which is adapted to detect the type of load and to operate depending on the detected load as leading or trailing edge phase-cut dimmer; - a storage unit configured to store a plurality of different dimmer mode tables for the corresponding plurality of pre-determined dimmer modes; wherein a first dimmer mode table from the plurality of dimmer mode tables, which corresponds to the first dimmer mode, comprises a plurality of state information records which define a state machine for operating the power converter according to a plurality of different operation modes; wherein the plurality of different operation modes comprise an energy transfer mode, during which the power converter is operated to provide power to an energy storage unit, and a linear operation mode, during which the power converter is operated as a load; - a state processor configured to select different operation modes from the plurality of different operation modes during a cycle of the waveform of the input signal; and - a first control unit configured to generate a first control signal for operating the power converter in accordance to the selected operation mode.