From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61760C04A94 for ; Fri, 4 Aug 2023 09:46:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 81F3083A; Fri, 4 Aug 2023 11:46:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 81F3083A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691142415; bh=GPngZKlTZVkTZ+yV34nZRPQl8pDG1+X3IxyvSVkQCyM=; h=Date:Subject:To:CC:References:From:In-Reply-To:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=jw2moR0tPvSuyR5y0pEQ2NB+l67n+Jgt02jAM4igZ1MtdLnigc5OjMnrP9SoIIIs9 cLd0tosxf/VZzTHbFRfR5ImcSwbVH+1/aJs2Gb6ei7Nm+4K+ovT2scbzhb2wkXC4h7 brXOUImHipUFQb9mNxSShcXYBu8YO0IjSa30ccFY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 13334F8053B; Fri, 4 Aug 2023 11:44:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 82906F80535; Fri, 4 Aug 2023 11:44:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1830EF8025A; Thu, 3 Aug 2023 10:38:13 +0200 (CEST) Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 32EE5F80087 for ; Thu, 3 Aug 2023 10:37:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 32EE5F80087 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id AC5BE8067; Thu, 3 Aug 2023 16:37:52 +0800 (CST) Received: from EXMBX172.cuchost.com (172.16.6.92) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 3 Aug 2023 16:37:52 +0800 Received: from [192.168.125.84] (183.27.98.54) by EXMBX172.cuchost.com (172.16.6.92) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 3 Aug 2023 16:37:51 +0800 Message-ID: <34c8c9d5-fad0-52ce-d1e6-798546005bfd@starfivetech.com> Date: Thu, 3 Aug 2023 16:37:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH v2 2/3] ASoC: starfive: Add JH7110 PWM-DAC driver Content-Language: en-US To: Mark Brown CC: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Claudiu Beznea , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Walker Chen , Xingyu Wu , Emil Renner Berthing , , , , References: <20230731032829.127864-1-hal.feng@starfivetech.com> <20230731032829.127864-3-hal.feng@starfivetech.com> <9b03c7ed-845c-494b-8c40-10d1fe923b15@sirena.org.uk> From: Hal Feng In-Reply-To: <9b03c7ed-845c-494b-8c40-10d1fe923b15@sirena.org.uk> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [183.27.98.54] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX172.cuchost.com (172.16.6.92) X-YovoleRuleAgent: yovoleflag X-MailFrom: hal.feng@starfivetech.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: OZU6SJSRVTJZ2DYHL6PRB5XIS5QLHLUW X-Message-ID-Hash: OZU6SJSRVTJZ2DYHL6PRB5XIS5QLHLUW X-Mailman-Approved-At: Fri, 04 Aug 2023 09:44:30 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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