On Mon, 31 Jul 2023 20:14:38 +0100, Mark Brown wrote: > On Mon, Jul 31, 2023 at 11:28:28AM +0800, Hal Feng wrote: > >> +static const struct jh7110_ct_pwmdac pwmdac_ct_data_shift[] = { >> + { .name = "left 0 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_0 }, >> + { .name = "left 1 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_1 }, >> + { .name = "left 2 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_2 }, >> + { .name = "left 3 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_3 }, >> + { .name = "left 4 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_4 }, >> + { .name = "left 5 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_5 }, >> + { .name = "left 6 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_6 }, >> + { .name = "left 7 bit", .vals = PWMDAC_DATA_LEFT_SHIFT_BIT_7 } >> +}; > > It's not clear to me why this is user selectable - what does the control > do? It's convenient to change the register values in user space with the control. But actually using fixed register configuration is enough. I will drop all these control in the next version. > >> +static int jh7110_pwmdac_put(struct snd_kcontrol *kcontrol, >> + struct snd_ctl_elem_value *ucontrol, >> + int pwmdac_ct) >> +{ >> + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); >> + struct jh7110_pwmdac_dev *dev = snd_soc_component_get_drvdata(component); >> + int sel = ucontrol->value.enumerated.item[0]; >> + unsigned int items; > >> + if (pwmdac_ct == PWMDAC_CT_SHIFT) >> + dev->shift = pwmdac_ct_shift[sel].vals; >> + else if (pwmdac_ct == PWMDAC_CT_DUTY_CYCLE) >> + dev->duty_cycle = pwmdac_ct_duty_cycle[sel].vals; >> + else if (pwmdac_ct == PWMDAC_CT_DATA_CHANGE) >> + dev->data_change = pwmdac_ct_data_change[sel].vals; >> + else if (pwmdac_ct == PWMDAC_CT_DATA_MODE) >> + dev->data_mode = pwmdac_ct_data_mode[sel].vals; >> + else if (pwmdac_ct == PWMDAC_CT_DATA_SHIFT) >> + dev->data_shift = pwmdac_ct_data_shift[sel].vals; >> + >> + return 0; >> +} > > _put() operations should return 1 if the control value changes so event > generation works - please test a card using this driver with the > mixer-test selftest, it'll identify this and a bunch of other potential > issues. Thanks for the correct, but it doesn't matter as I will drop these control later. > >> +static int jh7110_pwmdac_component_probe(struct snd_soc_component *component) >> +{ >> + snd_soc_add_component_controls(component, jh7110_pwmdac_snd_controls, >> + ARRAY_SIZE(jh7110_pwmdac_snd_controls)); >> + return 0; >> +} > > The driver can just point to the controls from the _driver struct and > skip having a probe() function. Thanks for your advice, but I would like to drop these control later. Thanks again for your review. Best regards, Hal