Received: by 2002:a05:6520:3645:b029:c0:f950:43e0 with SMTP id l5csp6299314lki; Thu, 4 Mar 2021 09:33:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXm0L7+n3bgQlJUBL8bG5YXTB3SQKyCy1w5a3w59byfNrkMXRYl1uFyAU3gc9plONu5WhG X-Received: by 2002:a17:907:2112:: with SMTP id qn18mr5376639ejb.220.1614879182554; Thu, 04 Mar 2021 09:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614879182; cv=none; d=google.com; s=arc-20160816; b=pncMVzdQSgxCo0QUH18f/0MEYX38iYrzGqYw09jIZASc/CdvEbo+Zbqp3OgkKwmrs5 KUDEH9+1JY88PahdOS3abpqq/NP3StoqM/C0C4CzV614XybkvVtxJ22dUoX9tfGv2CPp 6ZbLh2S0acI9rD/vnlSZl9NMAmqZ9mUozS0+HYFUatuqzg7rdIGHrOaf07OO0lMs1juf RnUVJaw0sQKVNBiBRmNxYlWfOI+JNnpHx1dazvaaHzBTZHrhUUJ3X5kq7Oh77U6q12Uv k8yjzoE1DufmV2ANDiwHvAyt+ia/xtk5Dk8jmZ2xLGbMAlE/HtvxXTpCvOIM+S3mrjA+ IJow== 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=8mVXAYfWCBNXZAA/N6HA7+o97j+lZ5I8zgnyvInO/mI=; b=Y0cEaP5Y/+8CEE5Ne0BzL5Jnqoxh+CXOTNWtlmFdVuLmBoATRilpGXC/eOqqbh+rJZ tGfA4RwyHfzXR6zAQ5lRbuE/hLSs1hlO1vXsd7H2MQ9mVJS1vEZlgy8B2WHolUkwijfi x90zzm9mppovR13SEQryw1UYYYiQQvMp/FHsikzpnO9Z8IQ5WW3+R8Ij6lZcfT7zRpjM 3AKIi3y7CAavNV5Z9k6NvvA4emEjE0ObvRl+xl/JjyViUO7mWktNxDTCIumwJJrNPJwh r+H0TePey78vi9GPwPosMJ8VQ+kPUH20WahEvyxtgei6Bk42GDHC1K1lxEGxnfzcxeCC Nr3Q== 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 w21si11146161ejb.465.2021.03.04.09.32.37; Thu, 04 Mar 2021 09:33:02 -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 S238291AbhCDNq7 (ORCPT + 99 others); Thu, 4 Mar 2021 08:46:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:40002 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233480AbhCDNqe (ORCPT ); Thu, 4 Mar 2021 08:46:34 -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 0AAB7AE47; Thu, 4 Mar 2021 13:45:53 +0000 (UTC) Date: Thu, 04 Mar 2021 14:45:51 +0100 Message-ID: From: Takashi Iwai To: Vitaly Rodionov Cc: Jaroslav Kysela , Takashi Iwai , , , Subject: Re: [PATCH 3/4] ALSA: hda/cirrus: Add jack detect interrupt support from CS42L42 companion codec. In-Reply-To: <20210303182959.5322-4-vitalyr@opensource.cirrus.com> References: <20210303182959.5322-1-vitalyr@opensource.cirrus.com> <20210303182959.5322-4-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:58 +0100, Vitaly Rodionov wrote: > @@ -1243,6 +1258,8 @@ static int patch_cs4213(struct hda_codec *codec) > #define CIR_I2C_QWRITE 0x005D > #define CIR_I2C_QREAD 0x005E > > +static struct mutex cs8409_i2c_mux; Any reason that this must be the global mutex? I suppose it can fit in own spec->i2c_mutex instead? > +static void cs8409_cs42l42_cap_sync_hook(struct hda_codec *codec, > + struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_value *ucontrol) > +{ > + struct cs_spec *spec = codec->spec; > + unsigned int curval, expval; > + /* CS8409 DMIC Pin only allows the setting of the Stream Parameters in > + * Power State D0. When a headset is unplugged, and the path is switched to > + * the DMIC, the Stream is restarted with the new ADC, but this is done in > + * Power State D3. Restart the Stream now DMIC is in D0. > + */ > + if (spec->gen.cur_adc == CS8409_CS42L42_DMIC_ADC_PIN_NID) { > + curval = snd_hda_codec_read(codec, spec->gen.cur_adc, > + 0, AC_VERB_GET_CONV, 0); > + expval = (spec->gen.cur_adc_stream_tag << 4) | 0; > + if (curval != expval) { > + codec_dbg(codec, "%s Restarting Stream after DMIC switch\n", __func__); > + __snd_hda_codec_cleanup_stream(codec, spec->gen.cur_adc, 1); > + snd_hda_codec_setup_stream(codec, spec->gen.cur_adc, > + spec->gen.cur_adc_stream_tag, 0, > + spec->gen.cur_adc_format); Hrm, this looks a big scary. We may need to reconsider how to handle this better later, but it's OK as long as you've tested with this code... > +static int cs8409_cs42l42_init(struct hda_codec *codec) > +{ > + int ret = 0; > + > + ret = snd_hda_gen_init(codec); > + > + if (!ret) { > + /* On Dell platforms with suspend D3 mode support we > + * have to re-initialise cs8409 bridge and companion > + * cs42l42 codec > + */ > + snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs); > + snd_hda_sequence_write(codec, cs8409_cs42l42_add_verbs); > + > + cs8409_cs42l42_hw_init(codec); Ah... the init stuff at resume appears finally here. This part should be in the second patch instead. > +static int cs8409_cs42l42_exec_verb(struct hdac_device *dev, > + unsigned int cmd, unsigned int flags, unsigned int *res) > +{ > + struct hda_codec *codec = container_of(dev, struct hda_codec, core); > + struct cs_spec *spec = codec->spec; > + > + unsigned int nid = 0; > + unsigned int verb = 0; The blank line above should be removed. > + case CS8409_CS42L42_HP_PIN_NID: > + if (verb == AC_VERB_GET_PIN_SENSE) { > + *res = (spec->cs42l42_hp_jack_in)?AC_PINSENSE_PRESENCE:0; The spaces are needed around operators. Similar coding-style issues are seen other places. Please try to run scripts/checkpatch.pl. thanks, Takashi