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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80A31C433E0 for ; Thu, 4 Mar 2021 13:51:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F4B364F40 for ; Thu, 4 Mar 2021 13:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241500AbhCDNuo (ORCPT ); Thu, 4 Mar 2021 08:50:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:43294 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238322AbhCDNuM (ORCPT ); Thu, 4 Mar 2021 08:50:12 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 43DB5AE44; Thu, 4 Mar 2021 13:49:31 +0000 (UTC) Date: Thu, 04 Mar 2021 14:49:31 +0100 Message-ID: From: Takashi Iwai To: Vitaly Rodionov Cc: Jaroslav Kysela , Takashi Iwai , , , , Stefan Binding Subject: Re: [PATCH 4/4] ALSA: hda/cirrus: Add Headphone and Headset MIC Volume Control In-Reply-To: <20210303182959.5322-5-vitalyr@opensource.cirrus.com> References: <20210303182959.5322-1-vitalyr@opensource.cirrus.com> <20210303182959.5322-5-vitalyr@opensource.cirrus.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 03 Mar 2021 19:29:59 +0100, Vitaly Rodionov wrote: > > +static int cs8409_cs42l42_volume_get(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); > + hda_nid_t nid = get_amp_nid(kcontrol); > + int chs = get_amp_channels(kcontrol); > + long *valp = ucontrol->value.integer.value; > + char vol = 0; > + > + codec_dbg(codec, "%s() nid: %d\n", __func__, nid); > + snd_hda_power_up(codec); > + switch (nid) { > + case CS8409_CS42L42_HP_PIN_NID: > + mutex_lock(&cs8409_i2c_mux); > + if (chs & 1) { > + vol = -(cs8409_i2c_read(codec, CS42L42_I2C_ADDR, > + CS8409_CS42L42_REG_HS_VOLUME_CHA, 1)); Better to cache the values instead of i2c read at each time? Then the unnecessary power up/down sequence can be avoided, too. thanks, Takashi