Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1608505pxb; Thu, 4 Mar 2021 16:13:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxwt+XwUSUpR4ytJu+NEZjCd2wB4b0kbtoDPrla+mABNkVvcjboq7H6msa7BaiqydyaFmN X-Received: by 2002:a02:a303:: with SMTP id q3mr6922364jai.32.1614903228727; Thu, 04 Mar 2021 16:13:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614903228; cv=none; d=google.com; s=arc-20160816; b=mVCGC3VtYE5ZCV8TkB8vZfv4YEhYWqToNsv+7pr1EtmYdZcsOnsr9PfkLUYIyMsfkV avKdDnaz5TbWvhrY62lRx8+bYitupAFllkq2o0abSwWl4B6xXudGit8SOVOreVPMxyme eSVydGYNdAG8jUGvA2V7nSrDGqQCA5kjqrJEdQkHzU7F3v0iKjpbXNbcqysCo2Bp4vlW c/a9A1hfxl4iIiEvQzM7hPn4MsJGDM8ndPfBbM7njBvG3Ppoe2RjsKaQ/+SAUYzZ1Rvw feFqVuoWjXw3hYgsvqXIQhcH8lKIcfNl56OUASeMCN56piy4L1ZMmqTt91zxoU99iIOt h+JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=xIQRG9Hd2wmrLzf6l4z4JnQib+EjPQNPOg+z8jb0F8k=; b=hKi791elWzmwoIClCskECzQQA8BNt8wcEYgqnQ9pZztx1szq2EDfHHD9wg8miAaRDq BFXDbxO3WEp+TkgWkxYDOs/9/IIYK5RYyhkXvqx7osDUZ0cZhufHyJmn86S1WXIH0gLw wugY0XlRuU9vPs0c/mVWYNG9GrfM68KIINujk0jm4BRbMDsTqnr2elRn2yGQq3uex7qE tl0BL0gRlQDwEtidVWJhZer98Hop1+BS0PaQeIKvW0nvNmQ9LMLjwnnq6CkYN+osNVlt QEWdVpi63bX6kBIVXKwb70l0AMxl9/vkTa16Dk2CIcJpB1mT6oygqK60slx6Bas6qtNb usBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si1040949ioq.6.2021.03.04.16.13.35; Thu, 04 Mar 2021 16:13:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241487AbhCDNun (ORCPT + 99 others); Thu, 4 Mar 2021 08:50:43 -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