From: Hal Feng <hal.feng@starfivetech.com>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Claudiu Beznea <claudiu.beznea@microchip.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Walker Chen <walker.chen@starfivetech.com>,
Xingyu Wu <xingyu.wu@starfivetech.com>,
Emil Renner Berthing <emil.renner.berthing@canonical.com>,
<alsa-devel@alsa-project.org>, <devicetree@vger.kernel.org>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] ASoC: starfive: Add JH7110 PWM-DAC driver
Date: Thu, 3 Aug 2023 16:37:50 +0800 [thread overview]
Message-ID: <34c8c9d5-fad0-52ce-d1e6-798546005bfd@starfivetech.com> (raw)
In-Reply-To: <9b03c7ed-845c-494b-8c40-10d1fe923b15@sirena.org.uk>
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
next prev parent reply other threads:[~2023-08-03 8:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 3:28 [PATCH v2 0/3] Add PWM-DAC audio support for StarFive JH7110 RISC-V SoC Hal Feng
2023-07-31 3:28 ` [PATCH v2 1/3] ASoC: dt-bindings: Add StarFive JH7110 PWM-DAC controller Hal Feng
2023-07-31 3:28 ` [PATCH v2 2/3] ASoC: starfive: Add JH7110 PWM-DAC driver Hal Feng
2023-07-31 7:06 ` Krzysztof Kozlowski
2023-08-03 3:00 ` Hal Feng
2023-07-31 19:14 ` Mark Brown
2023-08-03 8:37 ` Hal Feng [this message]
2023-07-31 3:28 ` [PATCH v2 3/3] riscv: dts: starfive: Add JH7110 PWM-DAC support Hal Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34c8c9d5-fad0-52ce-d1e6-798546005bfd@starfivetech.com \
--to=hal.feng@starfivetech.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=claudiu.beznea@microchip.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=emil.renner.berthing@canonical.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=tiwai@suse.com \
--cc=walker.chen@starfivetech.com \
--cc=xingyu.wu@starfivetech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).